Skip to content

Commit 402faef

Browse files
rianjsclaude
andcommitted
test: add root command tests for complete coverage
Add TestRootCommand to match gmail-ro test coverage: - Verifies command use, descriptions, version, and subcommands - gro now has 69 test functions matching gmail-ro Closes #7 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent fdbf2a4 commit 402faef

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

internal/cmd/root/root_test.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package root
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/assert"
7+
)
8+
9+
func TestRootCommand(t *testing.T) {
10+
t.Run("has correct use", func(t *testing.T) {
11+
assert.Equal(t, "gro", rootCmd.Use)
12+
})
13+
14+
t.Run("has short description", func(t *testing.T) {
15+
assert.NotEmpty(t, rootCmd.Short)
16+
})
17+
18+
t.Run("has long description", func(t *testing.T) {
19+
assert.NotEmpty(t, rootCmd.Long)
20+
assert.Contains(t, rootCmd.Long, "read-only")
21+
})
22+
23+
t.Run("has version set", func(t *testing.T) {
24+
assert.NotEmpty(t, rootCmd.Version)
25+
})
26+
27+
t.Run("has subcommands", func(t *testing.T) {
28+
subcommands := rootCmd.Commands()
29+
assert.GreaterOrEqual(t, len(subcommands), 3)
30+
31+
var names []string
32+
for _, sub := range subcommands {
33+
names = append(names, sub.Name())
34+
}
35+
assert.Contains(t, names, "init")
36+
assert.Contains(t, names, "config")
37+
assert.Contains(t, names, "mail")
38+
})
39+
}

0 commit comments

Comments
 (0)