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

Function TestTrustInspectCommand

cmd/docker-trust/trust/inspect_test.go:98–153  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

96}
97
98func TestTrustInspectCommand(t *testing.T) {
99 testCases := []struct {
100 doc string
101 args []string
102 notaryRepository func() (client.Repository, error)
103 golden string
104 }{
105 {
106 doc: "EmptyNotaryRepo",
107 args: []string{"reg/img:unsigned-tag"},
108 notaryRepository: notary.GetEmptyTargetsNotaryRepository,
109 golden: "trust-inspect-empty-repo.golden",
110 },
111 {
112 doc: "FullRepoWithoutSigners",
113 args: []string{"signed-repo"},
114 notaryRepository: notary.GetLoadedWithNoSignersNotaryRepository,
115 golden: "trust-inspect-full-repo-no-signers.golden",
116 },
117 {
118 doc: "OneTagWithoutSigners",
119 args: []string{"signed-repo:green"},
120 notaryRepository: notary.GetLoadedWithNoSignersNotaryRepository,
121 golden: "trust-inspect-one-tag-no-signers.golden",
122 },
123 {
124 doc: "FullRepoWithSigners",
125 args: []string{"signed-repo"},
126 notaryRepository: notary.GetLoadedNotaryRepository,
127 golden: "trust-inspect-full-repo-with-signers.golden",
128 },
129 {
130 doc: "MultipleFullReposWithSigners",
131 args: []string{"signed-repo", "signed-repo"},
132 notaryRepository: notary.GetLoadedNotaryRepository,
133 golden: "trust-inspect-multiple-repos-with-signers.golden",
134 },
135 {
136 doc: "UnsignedTagInSignedRepo",
137 args: []string{"signed-repo:unsigned"},
138 notaryRepository: notary.GetLoadedNotaryRepository,
139 golden: "trust-inspect-unsigned-tag-with-signers.golden",
140 },
141 }
142
143 for _, tc := range testCases {
144 t.Run(tc.doc, func(t *testing.T) {
145 cli := test.NewFakeCli(&fakeClient{})
146 cli.SetNotaryClient(tc.notaryRepository)
147 cmd := newInspectCommand(cli)
148 cmd.SetArgs(tc.args)
149 assert.NilError(t, cmd.Execute())
150 golden.Assert(t, cli.OutBuffer().String(), tc.golden)
151 })
152 }
153}

Callers

nothing calls this directly

Calls 5

SetNotaryClientMethod · 0.95
OutBufferMethod · 0.95
SetArgsMethod · 0.80
newInspectCommandFunction · 0.70
StringMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…