Skip to content

test: replace os.Args mutation with cobra command factory #47

Description

@mendsec

Context

The current integration tests in tests/integration_test.go mutate os.Args and os.Stdout globally. Even with the C6/C7 fixes in v0.2.0, the approach is fragile because Cobra's PersistentPreRun hooks and flag default values are set once at package init. The correct pattern is to expose a NewRootCmd() constructor in internal/cli that returns a fresh *cobra.Command per call, making each test fully isolated without process-level side effects.

Acceptance criteria

  • internal/cli exports NewRootCmd() *cobra.Command
  • All integration tests call NewRootCmd().ExecuteC() instead of the package-level cli.Execute()
  • os.Args is never mutated in any test file
  • go test -race -count=3 ./... passes deterministically
  • TestMain go build step retained for subprocess signal test only

Metadata

Metadata

Assignees

No one assigned

    Labels

    refactorCode refactoringtestingTesting-related

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions