(t *testing.T)
| 51 | } |
| 52 | |
| 53 | func TestNewImportCommandSuccess(t *testing.T) { |
| 54 | testCases := []struct { |
| 55 | name string |
| 56 | args []string |
| 57 | imageImportFunc func(source client.ImageImportSource, ref string, options client.ImageImportOptions) (client.ImageImportResult, error) |
| 58 | }{ |
| 59 | { |
| 60 | name: "simple", |
| 61 | args: []string{"testdata/import-command-success.input.txt"}, |
| 62 | }, |
| 63 | { |
| 64 | name: "terminal-source", |
| 65 | args: []string{"-"}, |
| 66 | }, |
| 67 | { |
| 68 | name: "double", |
| 69 | args: []string{"-", "image:local"}, |
| 70 | imageImportFunc: func(source client.ImageImportSource, ref string, options client.ImageImportOptions) (client.ImageImportResult, error) { |
| 71 | assert.Check(t, is.Equal("image:local", ref)) |
| 72 | return io.NopCloser(strings.NewReader("")), nil |
| 73 | }, |
| 74 | }, |
| 75 | { |
| 76 | name: "message", |
| 77 | args: []string{"--message", "test message", "-"}, |
| 78 | imageImportFunc: func(source client.ImageImportSource, ref string, options client.ImageImportOptions) (client.ImageImportResult, error) { |
| 79 | assert.Check(t, is.Equal("test message", options.Message)) |
| 80 | return io.NopCloser(strings.NewReader("")), nil |
| 81 | }, |
| 82 | }, |
| 83 | { |
| 84 | name: "change", |
| 85 | args: []string{"--change", "ENV DEBUG=true", "-"}, |
| 86 | imageImportFunc: func(source client.ImageImportSource, ref string, options client.ImageImportOptions) (client.ImageImportResult, error) { |
| 87 | assert.Check(t, is.Equal("ENV DEBUG=true", options.Changes[0])) |
| 88 | return io.NopCloser(strings.NewReader("")), nil |
| 89 | }, |
| 90 | }, |
| 91 | { |
| 92 | name: "change legacy syntax", |
| 93 | args: []string{"--change", "ENV DEBUG true", "-"}, |
| 94 | imageImportFunc: func(source client.ImageImportSource, ref string, options client.ImageImportOptions) (client.ImageImportResult, error) { |
| 95 | assert.Check(t, is.Equal("ENV DEBUG true", options.Changes[0])) |
| 96 | return io.NopCloser(strings.NewReader("")), nil |
| 97 | }, |
| 98 | }, |
| 99 | } |
| 100 | for _, tc := range testCases { |
| 101 | t.Run(tc.name, func(t *testing.T) { |
| 102 | cmd := newImportCommand(test.NewFakeCli(&fakeClient{imageImportFunc: tc.imageImportFunc})) |
| 103 | cmd.SetOut(io.Discard) |
| 104 | cmd.SetErr(io.Discard) |
| 105 | cmd.SetArgs(tc.args) |
| 106 | assert.NilError(t, cmd.Execute()) |
| 107 | }) |
| 108 | } |
| 109 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…