Skip to content

test: add unit tests for internal/init — driver install and removal #19

@jpleva91

Description

@jpleva91

Problem

internal/init/init.go has zero test coverage. The init package installs chitin hooks into agent driver configs (Claude Code, Copilot, Codex, Gemini). If Run() writes bad config, users get silent governance bypass.

Acceptance Criteria

  • Test Run() creates the config directory if it does not exist
  • Test Run() writes the correct settings file for each driver (claude, copilot, codex, gemini)
  • Test Run() creates a starter chitin.yaml if missing
  • Test Run() skips chitin.yaml if it already exists
  • Test Run() creates .chitin-identity file
  • Test Run() in global mode uses the global config dir
  • Test Run() returns error for unknown driver name
  • Test Remove() deletes the settings file
  • Test Remove() returns error for unknown driver name
  • All tests use t.TempDir() for filesystem isolation
  • All tests pass with go test ./internal/init/...

Hints

  • File: internal/init/init.go
  • Functions: Run(driverName string, global bool, projectDir string), Remove(driverName string, global bool, projectDir string)
  • Templates in internal/init/templates.go: ClaudeSettings, CopilotHooks, CodexHooks, GeminiSettings, StarterPolicy
  • Driver map: Drivers — keys are "claude", "copilot", "codex", "gemini"
  • Create test file: internal/init/init_test.go

Generated by /forge fill

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions