package git import ( "testing" ) func TestIsRepo(t *testing.T) { // This test assumes we're running in a git repo result := IsRepo() if !result { t.Log("Warning: Not in a git repository, test may be running in unexpected environment") } } func TestRun(t *testing.T) { tests := []struct { name string args []string shouldErr bool }{ { name: "version command succeeds", args: []string{"--version"}, shouldErr: false, }, { name: "invalid command fails", args: []string{"invalid-command-xyz"}, shouldErr: true, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { output, err := Run(tt.args) if tt.shouldErr { if err == nil { t.Errorf("Run() expected error, got nil") } } else { if err != nil { t.Errorf("Run() unexpected error: %v", err) } if output == "" { t.Errorf("Run() expected output, got empty string") } } }) } } func TestGitRunner(t *testing.T) { runner := NewRunner() // Test Run output, err := runner.Run([]string{"--version"}) if err != nil { t.Errorf("GitRunner.Run() unexpected error: %v", err) } if output == "" { t.Errorf("GitRunner.Run() expected output, got empty string") } // Test IsRepo _ = runner.IsRepo() // Just ensure it doesn't panic }