MCPcopy Index your code
hub / github.com/cli/cli / TestValidAliasNameFunc

Function TestValidAliasNameFunc

pkg/cmd/alias/shared/validations_test.go:10–32  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestValidAliasNameFunc(t *testing.T) {
11 // Create fake command structure for testing.
12 issueCmd := &cobra.Command{Use: "issue"}
13 prCmd := &cobra.Command{Use: "pr"}
14 prCmd.AddCommand(&cobra.Command{Use: "checkout"})
15
16 cmd := &cobra.Command{}
17 cmd.AddCommand(prCmd)
18 cmd.AddCommand(issueCmd)
19
20 f := ValidAliasNameFunc(cmd)
21
22 assert.False(t, f("pr"))
23 assert.False(t, f("pr checkout"))
24 assert.False(t, f("issue"))
25 assert.False(t, f("repo list"))
26
27 assert.True(t, f("ps"))
28 assert.True(t, f("checkout"))
29 assert.True(t, f("issue erase"))
30 assert.True(t, f("pr erase"))
31 assert.True(t, f("pr checkout branch"))
32}
33
34func TestValidAliasExpansionFunc(t *testing.T) {
35 // Create fake command structure for testing.

Callers

nothing calls this directly

Calls 1

ValidAliasNameFuncFunction · 0.85

Tested by

no test coverage detected