(t *testing.T)
| 49 | } |
| 50 | |
| 51 | func TestCheckpointCreateWithOptions(t *testing.T) { |
| 52 | const ( |
| 53 | containerName = "container-foo" |
| 54 | checkpointName = "checkpoint-bar" |
| 55 | checkpointDir = "/dir/foo" |
| 56 | ) |
| 57 | |
| 58 | for _, tc := range []bool{true, false} { |
| 59 | leaveRunning := strconv.FormatBool(tc) |
| 60 | t.Run("leave-running="+leaveRunning, func(t *testing.T) { |
| 61 | var actualContainerName string |
| 62 | var actualOptions client.CheckpointCreateOptions |
| 63 | cli := test.NewFakeCli(&fakeClient{ |
| 64 | checkpointCreateFunc: func(container string, options client.CheckpointCreateOptions) (client.CheckpointCreateResult, error) { |
| 65 | actualContainerName = container |
| 66 | actualOptions = options |
| 67 | return client.CheckpointCreateResult{}, nil |
| 68 | }, |
| 69 | }) |
| 70 | cmd := newCreateCommand(cli) |
| 71 | cmd.SetOut(io.Discard) |
| 72 | cmd.SetErr(io.Discard) |
| 73 | cmd.SetArgs([]string{containerName, checkpointName}) |
| 74 | assert.Check(t, cmd.Flags().Set("leave-running", leaveRunning)) |
| 75 | assert.Check(t, cmd.Flags().Set("checkpoint-dir", checkpointDir)) |
| 76 | assert.NilError(t, cmd.Execute()) |
| 77 | assert.Check(t, is.Equal(actualContainerName, containerName)) |
| 78 | expected := client.CheckpointCreateOptions{ |
| 79 | CheckpointID: checkpointName, |
| 80 | CheckpointDir: checkpointDir, |
| 81 | Exit: !tc, |
| 82 | } |
| 83 | assert.Check(t, is.Equal(actualOptions, expected)) |
| 84 | assert.Check(t, is.Equal(strings.TrimSpace(cli.OutBuffer().String()), checkpointName)) |
| 85 | }) |
| 86 | } |
| 87 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…