MCPcopy Create free account
hub / github.com/celer-pkg/celer / TestDeployCmd_Completion

Function TestDeployCmd_Completion

cmds/cmd_deploy_test.go:113–156  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

111}
112
113func TestDeployCmd_Completion(t *testing.T) {
114 dirs.RemoveAllForTest()
115
116 deploy := deployCmd{}
117 cmd := deploy.Command(configs.NewCeler())
118
119 tests := []struct {
120 name string
121 toComplete string
122 expected []string
123 }{
124 {
125 name: "complete_long_force_flag",
126 toComplete: "--fo",
127 expected: []string{"--force"},
128 },
129 {
130 name: "complete_short_force_flag",
131 toComplete: "-f",
132 expected: []string{"-f"},
133 },
134 {
135 name: "complete_snapshot_flag",
136 toComplete: "--sna",
137 expected: []string{"--snapshot"},
138 },
139 }
140
141 for _, test := range tests {
142 t.Run(test.name, func(t *testing.T) {
143 suggestions, directive := deploy.completion(cmd, []string{}, test.toComplete)
144
145 if directive != cobra.ShellCompDirectiveNoFileComp {
146 t.Fatalf("expected directive %v, got %v", cobra.ShellCompDirectiveNoFileComp, directive)
147 }
148
149 for _, expected := range test.expected {
150 if !slices.Contains(suggestions, expected) {
151 t.Fatalf("expected completion %s, got %v", expected, suggestions)
152 }
153 }
154 })
155 }
156}
157
158// setupTestRepo creates a bare git repo as clone source in a temp directory
159// and returns its path along with known commit hashes for testing.

Callers

nothing calls this directly

Calls 4

CommandMethod · 0.95
completionMethod · 0.95
RemoveAllForTestFunction · 0.92
NewCelerFunction · 0.92

Tested by

no test coverage detected