MCPcopy Create free account
hub / github.com/conforma/cli / Test_ValidateImageCommandImages

Function Test_ValidateImageCommandImages

cmd/validate/image_test.go:393–479  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

391}
392
393func Test_ValidateImageCommandImages(t *testing.T) {
394 validateImageCmd := validateImageCmd(happyValidator())
395 cmd := setUpCobra(validateImageCmd)
396
397 client := fake.FakeClient{}
398 commonMockClient(&client)
399 ctx := utils.WithFS(context.Background(), afero.NewMemMapFs())
400 ctx = oci.WithClient(ctx, &client)
401 cmd.SetContext(ctx)
402
403 effectiveTimeTest := time.Now().UTC().Format(time.RFC3339Nano)
404
405 images := `{
406 "components": [
407 {
408 "name": "bacon",
409 "containerImage": "registry.localhost/bacon:v2.0",
410 "source": {
411 "git": {
412 "url": "https://git.localhost/bacon.git",
413 "revision": "8abf15bef376e0e21f1f9e9c3d74483d5018f3d5"
414 }
415 }
416 },
417 {
418 "name": "spam",
419 "containerImage": "registry.localhost/spam:v1.0",
420 "source": {
421 "git": {
422 "url": "https://git.localhost/spam.git",
423 "revision": "ded982e702e07bb7b6effafdc353db3fe172c83f"
424 }
425 }
426 }
427 ]
428 }`
429
430 cmd.SetArgs(append(rootArgs, []string{
431 "--images",
432 images,
433 "--policy",
434 fmt.Sprintf(`{"publicKey": %s}`, utils.TestPublicKeyJSON),
435 "--effective-time",
436 effectiveTimeTest,
437 }...))
438
439 var out bytes.Buffer
440 cmd.SetOut(&out)
441
442 utils.SetTestRekorPublicKey(t)
443
444 err := cmd.Execute()
445 assert.NoError(t, err)
446 assert.JSONEq(t, fmt.Sprintf(`{
447 "success": true,
448 "ec-version": "development",
449 "effective-time": %q,
450 "key": %s,

Callers

nothing calls this directly

Calls 8

WithFSFunction · 0.92
WithClientFunction · 0.92
SetTestRekorPublicKeyFunction · 0.92
validateImageCmdFunction · 0.85
happyValidatorFunction · 0.85
commonMockClientFunction · 0.85
setUpCobraFunction · 0.70
StringMethod · 0.45

Tested by

no test coverage detected