(t *testing.T)
| 14 | ) |
| 15 | |
| 16 | func TestTrustRevokeCommandErrors(t *testing.T) { |
| 17 | testCases := []struct { |
| 18 | name string |
| 19 | args []string |
| 20 | expectedError string |
| 21 | }{ |
| 22 | { |
| 23 | name: "not-enough-args", |
| 24 | expectedError: "requires 1 argument", |
| 25 | }, |
| 26 | { |
| 27 | name: "too-many-args", |
| 28 | args: []string{"remote1", "remote2"}, |
| 29 | expectedError: "requires 1 argument", |
| 30 | }, |
| 31 | { |
| 32 | name: "sha-reference", |
| 33 | args: []string{"870d292919d01a0af7e7f056271dc78792c05f55f49b9b9012b6d89725bd9abd"}, |
| 34 | expectedError: "invalid repository name", |
| 35 | }, |
| 36 | { |
| 37 | name: "invalid-img-reference", |
| 38 | args: []string{"ALPINE"}, |
| 39 | expectedError: "invalid reference format", |
| 40 | }, |
| 41 | { |
| 42 | name: "digest-reference", |
| 43 | args: []string{"ubuntu@sha256:45b23dee08af5e43a7fea6c4cf9c25ccf269ee113168c19722f87876677c5cb2"}, |
| 44 | expectedError: "cannot use a digest reference for IMAGE:TAG", |
| 45 | }, |
| 46 | } |
| 47 | for _, tc := range testCases { |
| 48 | cmd := newRevokeCommand( |
| 49 | test.NewFakeCli(&fakeClient{})) |
| 50 | cmd.SetArgs(tc.args) |
| 51 | cmd.SetOut(io.Discard) |
| 52 | cmd.SetErr(io.Discard) |
| 53 | assert.ErrorContains(t, cmd.Execute(), tc.expectedError) |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | func TestTrustRevokeCommand(t *testing.T) { |
| 58 | revokeCancelledError := "trust revoke has been cancelled" |
nothing calls this directly
no test coverage detected
searching dependent graphs…