(t *testing.T)
| 14 | ) |
| 15 | |
| 16 | func TestCheckpointCreateErrors(t *testing.T) { |
| 17 | testCases := []struct { |
| 18 | args []string |
| 19 | checkpointCreateFunc func(container string, options client.CheckpointCreateOptions) (client.CheckpointCreateResult, error) |
| 20 | expectedError string |
| 21 | }{ |
| 22 | { |
| 23 | args: []string{"too-few-arguments"}, |
| 24 | expectedError: "requires 2 arguments", |
| 25 | }, |
| 26 | { |
| 27 | args: []string{"too", "many", "arguments"}, |
| 28 | expectedError: "requires 2 arguments", |
| 29 | }, |
| 30 | { |
| 31 | args: []string{"foo", "bar"}, |
| 32 | checkpointCreateFunc: func(container string, options client.CheckpointCreateOptions) (client.CheckpointCreateResult, error) { |
| 33 | return client.CheckpointCreateResult{}, errors.New("error creating checkpoint for container foo") |
| 34 | }, |
| 35 | expectedError: "error creating checkpoint for container foo", |
| 36 | }, |
| 37 | } |
| 38 | |
| 39 | for _, tc := range testCases { |
| 40 | cli := test.NewFakeCli(&fakeClient{ |
| 41 | checkpointCreateFunc: tc.checkpointCreateFunc, |
| 42 | }) |
| 43 | cmd := newCreateCommand(cli) |
| 44 | cmd.SetArgs(tc.args) |
| 45 | cmd.SetOut(io.Discard) |
| 46 | cmd.SetErr(io.Discard) |
| 47 | assert.ErrorContains(t, cmd.Execute(), tc.expectedError) |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | func TestCheckpointCreateWithOptions(t *testing.T) { |
| 52 | const ( |
nothing calls this directly
no test coverage detected
searching dependent graphs…