(t *testing.T)
| 21 | ) |
| 22 | |
| 23 | func TestPrunePromptFilters(t *testing.T) { |
| 24 | cli := test.NewFakeCli(&fakeClient{version: "1.51"}) |
| 25 | cli.SetConfigFile(&configfile.ConfigFile{ |
| 26 | PruneFilters: []string{"label!=never=remove-me", "label=remove=me"}, |
| 27 | }) |
| 28 | cmd := newPruneCommand(cli) |
| 29 | cmd.SetArgs([]string{"--filter", "until=24h", "--filter", "label=hello-world", "--filter", "label!=foo=bar", "--filter", "label=bar=baz"}) |
| 30 | cmd.SetOut(io.Discard) |
| 31 | cmd.SetErr(io.Discard) |
| 32 | |
| 33 | assert.ErrorContains(t, cmd.Execute(), "system prune has been cancelled") |
| 34 | expected := `WARNING! This will remove: |
| 35 | - all stopped containers |
| 36 | - all networks not used by at least one container |
| 37 | - all dangling images |
| 38 | - unused build cache |
| 39 | |
| 40 | Items to be pruned will be filtered with: |
| 41 | - label!=foo=bar |
| 42 | - label!=never=remove-me |
| 43 | - label=bar=baz |
| 44 | - label=hello-world |
| 45 | - label=remove=me |
| 46 | - until=24h |
| 47 | |
| 48 | Are you sure you want to continue? [y/N] ` |
| 49 | assert.Check(t, is.Equal(expected, cli.OutBuffer().String())) |
| 50 | } |
| 51 | |
| 52 | func TestSystemPrunePromptTermination(t *testing.T) { |
| 53 | ctx, cancel := context.WithCancel(context.Background()) |
nothing calls this directly
no test coverage detected
searching dependent graphs…