Skip to content

Commit 3adf913

Browse files
committed
vibe code tests
1 parent c879240 commit 3adf913

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed

cmd/root_test.go

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
package cmd
2+
3+
import (
4+
"testing"
5+
6+
"github.com/spf13/cobra"
7+
"github.com/stretchr/testify/assert"
8+
)
9+
10+
func TestIsAuthExempt(t *testing.T) {
11+
tests := []struct {
12+
name string
13+
cmd *cobra.Command
14+
expected bool
15+
}{
16+
{
17+
name: "root command is exempt",
18+
cmd: rootCmd,
19+
expected: true,
20+
},
21+
{
22+
name: "login command is exempt",
23+
cmd: loginCmd,
24+
expected: true,
25+
},
26+
{
27+
name: "logout command is exempt",
28+
cmd: logoutCmd,
29+
expected: true,
30+
},
31+
{
32+
name: "top-level create command is exempt",
33+
cmd: createCmd,
34+
expected: true,
35+
},
36+
{
37+
name: "browser-pools create subcommand requires auth",
38+
cmd: browserPoolsCreateCmd,
39+
expected: false,
40+
},
41+
{
42+
name: "browsers create subcommand requires auth",
43+
cmd: browsersCreateCmd,
44+
expected: false,
45+
},
46+
{
47+
name: "profiles create subcommand requires auth",
48+
cmd: profilesCreateCmd,
49+
expected: false,
50+
},
51+
{
52+
name: "browser-pools list requires auth",
53+
cmd: browserPoolsListCmd,
54+
expected: false,
55+
},
56+
{
57+
name: "browsers list requires auth",
58+
cmd: browsersListCmd,
59+
expected: false,
60+
},
61+
{
62+
name: "deploy command requires auth",
63+
cmd: deployCmd,
64+
expected: false,
65+
},
66+
{
67+
name: "invoke command requires auth",
68+
cmd: invokeCmd,
69+
expected: false,
70+
},
71+
}
72+
73+
for _, tt := range tests {
74+
t.Run(tt.name, func(t *testing.T) {
75+
result := isAuthExempt(tt.cmd)
76+
assert.Equal(t, tt.expected, result, "isAuthExempt(%s) = %v, want %v", tt.cmd.Name(), result, tt.expected)
77+
})
78+
}
79+
}

0 commit comments

Comments
 (0)