|
1 | 1 | package gitignore_go |
| 2 | + |
| 3 | +import ( |
| 4 | + "testing" |
| 5 | + |
| 6 | + "github.com/Robert076/code-buddy/internal/utils/capture_output" |
| 7 | + "github.com/stretchr/testify/assert" |
| 8 | +) |
| 9 | + |
| 10 | +func TestGitignoreCommandGo_Name(t *testing.T) { |
| 11 | + cmd := &GitignoreCommandGo{} |
| 12 | + want := "go" |
| 13 | + |
| 14 | + if got := cmd.Name(); got != want { |
| 15 | + t.Errorf("GitignoreCommandGo_Name() got %v, want %v", got, want) |
| 16 | + } |
| 17 | +} |
| 18 | + |
| 19 | +func TestGitignoreCommandGo_Description(t *testing.T) { |
| 20 | + cmd := &GitignoreCommandGo{} |
| 21 | + want := "Returns a gitignore template for go projects" |
| 22 | + |
| 23 | + if got := cmd.Description(); got != want { |
| 24 | + t.Errorf("GitignoreCommandGo_Description() got %v, want %v", got, want) |
| 25 | + } |
| 26 | +} |
| 27 | + |
| 28 | +func TestGitignoreCommandGo_Subcommands(t *testing.T) { |
| 29 | + cmd := &GitignoreCommandGo{} |
| 30 | + noSubcommands := len(cmd.Subcommands()) |
| 31 | + |
| 32 | + if noSubcommands != 0 { |
| 33 | + t.Errorf("Expected subcommands length 0, since it's a leaf command, got %v", noSubcommands) |
| 34 | + } |
| 35 | +} |
| 36 | + |
| 37 | +func TestGitignoreCommandGo_Run(t *testing.T) { |
| 38 | + cmd := &GitignoreCommandGo{} |
| 39 | + |
| 40 | + output := capture_output.CaptureOutput(func() { |
| 41 | + cmd.Run([]string{}) |
| 42 | + }) |
| 43 | + assert.Contains(t, output, ".env") |
| 44 | + assert.Contains(t, output, "# env file") |
| 45 | + assert.Contains(t, output, ".exe") |
| 46 | +} |
0 commit comments