MCPcopy Index your code
hub / github.com/docker/cli / TestPrunePromptFilters

Function TestPrunePromptFilters

cli/command/system/prune_test.go:23–50  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

21)
22
23func 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
48Are you sure you want to continue? [y/N] `
49 assert.Check(t, is.Equal(expected, cli.OutBuffer().String()))
50}
51
52func TestSystemPrunePromptTermination(t *testing.T) {
53 ctx, cancel := context.WithCancel(context.Background())

Callers

nothing calls this directly

Calls 7

SetConfigFileMethod · 0.95
OutBufferMethod · 0.95
SetArgsMethod · 0.80
newPruneCommandFunction · 0.70
StringMethod · 0.65
SetOutMethod · 0.45
SetErrMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…