MCPcopy Create free account
hub / github.com/docker/cli / TestMatchHookConfig

Function TestMatchHookConfig

cli-plugins/manager/hooks_test.go:207–259  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

205}
206
207func TestMatchHookConfig(t *testing.T) {
208 testCases := []struct {
209 doc string
210 configuredHooks string
211 subCmd string
212 expectedMatch string
213 expectedOk bool
214 }{
215 {
216 doc: "empty config",
217 configuredHooks: "",
218 subCmd: "build",
219 expectedMatch: "",
220 expectedOk: false,
221 },
222 {
223 doc: "exact match",
224 configuredHooks: "build",
225 subCmd: "build",
226 expectedMatch: "build",
227 expectedOk: true,
228 },
229 {
230 doc: "prefix match",
231 configuredHooks: "image",
232 subCmd: "image ls",
233 expectedMatch: "image",
234 expectedOk: true,
235 },
236 {
237 doc: "comma-separated match",
238 configuredHooks: "pull,build,push",
239 subCmd: "build",
240 expectedMatch: "build",
241 expectedOk: true,
242 },
243 {
244 doc: "no match",
245 configuredHooks: "pull,push",
246 subCmd: "build",
247 expectedMatch: "",
248 expectedOk: false,
249 },
250 }
251
252 for _, tc := range testCases {
253 t.Run(tc.doc, func(t *testing.T) {
254 match, ok := matchHookConfig(tc.configuredHooks, tc.subCmd)
255 assert.Equal(t, ok, tc.expectedOk)
256 assert.Equal(t, match, tc.expectedMatch)
257 })
258 }
259}
260
261func TestAppendNextSteps(t *testing.T) {
262 testCases := []struct {

Callers

nothing calls this directly

Calls 1

matchHookConfigFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…