(t *testing.T)
| 47 | } |
| 48 | |
| 49 | func TestNewImagesCommandSuccess(t *testing.T) { |
| 50 | testCases := []struct { |
| 51 | name string |
| 52 | args []string |
| 53 | imageFormat string |
| 54 | imageListFunc func(options client.ImageListOptions) (client.ImageListResult, error) |
| 55 | }{ |
| 56 | { |
| 57 | name: "simple", |
| 58 | }, |
| 59 | { |
| 60 | name: "format", |
| 61 | imageFormat: "raw", |
| 62 | }, |
| 63 | { |
| 64 | name: "quiet-format", |
| 65 | args: []string{"-q"}, |
| 66 | imageFormat: "table", |
| 67 | }, |
| 68 | { |
| 69 | name: "match-name", |
| 70 | args: []string{"image"}, |
| 71 | imageListFunc: func(options client.ImageListOptions) (client.ImageListResult, error) { |
| 72 | assert.Check(t, options.Filters["reference"]["image"]) |
| 73 | return client.ImageListResult{}, nil |
| 74 | }, |
| 75 | }, |
| 76 | { |
| 77 | name: "filters", |
| 78 | args: []string{"--filter", "name=value"}, |
| 79 | imageListFunc: func(options client.ImageListOptions) (client.ImageListResult, error) { |
| 80 | assert.Check(t, options.Filters["name"]["value"]) |
| 81 | return client.ImageListResult{}, nil |
| 82 | }, |
| 83 | }, |
| 84 | } |
| 85 | for _, tc := range testCases { |
| 86 | t.Run(tc.name, func(t *testing.T) { |
| 87 | cli := test.NewFakeCli(&fakeClient{imageListFunc: tc.imageListFunc}) |
| 88 | cli.SetConfigFile(&configfile.ConfigFile{ImagesFormat: tc.imageFormat}) |
| 89 | cmd := newImagesCommand(cli) |
| 90 | cmd.SetOut(io.Discard) |
| 91 | cmd.SetErr(io.Discard) |
| 92 | cmd.SetArgs(nilToEmptySlice(tc.args)) |
| 93 | err := cmd.Execute() |
| 94 | assert.NilError(t, err) |
| 95 | golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("list-command-success.%s.golden", tc.name)) |
| 96 | }) |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | func TestNewListCommandAlias(t *testing.T) { |
| 101 | cmd := newListCommand(test.NewFakeCli(&fakeClient{})) |
nothing calls this directly
no test coverage detected
searching dependent graphs…