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

Function TestTrustSignCommandErrors

cmd/docker-trust/trust/sign_test.go:24–70  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

22)
23
24func TestTrustSignCommandErrors(t *testing.T) {
25 testCases := []struct {
26 name string
27 args []string
28 expectedError string
29 }{
30 {
31 name: "not-enough-args",
32 expectedError: "requires 1 argument",
33 },
34 {
35 name: "too-many-args",
36 args: []string{"image", "tag"},
37 expectedError: "requires 1 argument",
38 },
39 {
40 name: "sha-reference",
41 args: []string{"870d292919d01a0af7e7f056271dc78792c05f55f49b9b9012b6d89725bd9abd"},
42 expectedError: "invalid repository name",
43 },
44 {
45 name: "invalid-img-reference",
46 args: []string{"ALPINE:latest"},
47 expectedError: "invalid reference format",
48 },
49 {
50 name: "no-tag",
51 args: []string{"reg/img"},
52 expectedError: "no tag specified for reg/img",
53 },
54 {
55 name: "digest-reference",
56 args: []string{"ubuntu@sha256:45b23dee08af5e43a7fea6c4cf9c25ccf269ee113168c19722f87876677c5cb2"},
57 expectedError: "cannot use a digest reference for IMAGE:TAG",
58 },
59 }
60 // change to a tmpdir
61 config.SetDir(t.TempDir())
62 for _, tc := range testCases {
63 cmd := newSignCommand(
64 test.NewFakeCli(&fakeClient{}))
65 cmd.SetArgs(tc.args)
66 cmd.SetOut(io.Discard)
67 cmd.SetErr(io.Discard)
68 assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
69 }
70}
71
72func TestTrustSignCommandOfflineErrors(t *testing.T) {
73 cli := test.NewFakeCli(&fakeClient{})

Callers

nothing calls this directly

Calls 4

newSignCommandFunction · 0.85
SetArgsMethod · 0.80
SetOutMethod · 0.45
SetErrMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…