(t *testing.T)
| 205 | } |
| 206 | |
| 207 | func 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 | |
| 261 | func TestAppendNextSteps(t *testing.T) { |
| 262 | testCases := []struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…