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

Function TestManifestCreateAmend

cli/command/manifest/create_test.go:46–77  ·  view source on GitHub ↗

create a manifest list, then overwrite it, and inspect to see if the old one is still there

(t *testing.T)

Source from the content-addressed store, hash-verified

44
45// create a manifest list, then overwrite it, and inspect to see if the old one is still there
46func TestManifestCreateAmend(t *testing.T) {
47 manifestStore := store.NewStore(t.TempDir())
48
49 cli := test.NewFakeCli(nil)
50 cli.SetManifestStore(manifestStore)
51
52 namedRef := ref(t, "alpine:3.0")
53 imageManifest := fullImageManifest(t, namedRef)
54 err := manifestStore.Save(ref(t, "list:v1"), namedRef, imageManifest)
55 assert.NilError(t, err)
56 namedRef = ref(t, "alpine:3.1")
57 imageManifest = fullImageManifest(t, namedRef)
58 err = manifestStore.Save(ref(t, "list:v1"), namedRef, imageManifest)
59 assert.NilError(t, err)
60
61 cmd := newCreateListCommand(cli)
62 cmd.SetArgs([]string{"example.com/list:v1", "example.com/alpine:3.1"})
63 cmd.Flags().Set("amend", "true")
64 cmd.SetOut(io.Discard)
65 err = cmd.Execute()
66 assert.NilError(t, err)
67
68 // make a new cli to clear the buffers
69 cli = test.NewFakeCli(nil)
70 cli.SetManifestStore(manifestStore)
71 inspectCmd := newInspectCommand(cli)
72 inspectCmd.SetArgs([]string{"example.com/list:v1"})
73 assert.NilError(t, inspectCmd.Execute())
74 actual := cli.OutBuffer()
75 expected := golden.Get(t, "inspect-manifest-list.golden")
76 assert.Check(t, is.Equal(string(expected), actual.String()))
77}
78
79// attempt to overwrite a saved manifest and get refused
80func TestManifestCreateRefuseAmend(t *testing.T) {

Callers

nothing calls this directly

Calls 12

SetManifestStoreMethod · 0.95
SaveMethod · 0.95
OutBufferMethod · 0.95
fullImageManifestFunction · 0.85
newCreateListCommandFunction · 0.85
SetArgsMethod · 0.80
refFunction · 0.70
newInspectCommandFunction · 0.70
GetMethod · 0.65
StringMethod · 0.65
SetMethod · 0.45
SetOutMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…