github.com/xeptore/docker-cli@v20.10.14+incompatible/cli/command/system/prune_test.go (about) 1 package system 2 3 import ( 4 "testing" 5 6 "github.com/docker/cli/cli/config/configfile" 7 "github.com/docker/cli/internal/test" 8 "gotest.tools/v3/assert" 9 is "gotest.tools/v3/assert/cmp" 10 ) 11 12 func TestPrunePromptPre131DoesNotIncludeBuildCache(t *testing.T) { 13 cli := test.NewFakeCli(&fakeClient{version: "1.30"}) 14 cmd := newPruneCommand(cli) 15 cmd.SetArgs([]string{}) 16 assert.NilError(t, cmd.Execute()) 17 expected := `WARNING! This will remove: 18 - all stopped containers 19 - all networks not used by at least one container 20 - all dangling images 21 22 Are you sure you want to continue? [y/N] ` 23 assert.Check(t, is.Equal(expected, cli.OutBuffer().String())) 24 } 25 26 func TestPrunePromptFilters(t *testing.T) { 27 cli := test.NewFakeCli(&fakeClient{version: "1.31"}) 28 cli.SetConfigFile(&configfile.ConfigFile{ 29 PruneFilters: []string{"label!=never=remove-me", "label=remove=me"}, 30 }) 31 cmd := newPruneCommand(cli) 32 cmd.SetArgs([]string{"--filter", "until=24h", "--filter", "label=hello-world", "--filter", "label!=foo=bar", "--filter", "label=bar=baz"}) 33 34 assert.NilError(t, cmd.Execute()) 35 expected := `WARNING! This will remove: 36 - all stopped containers 37 - all networks not used by at least one container 38 - all dangling images 39 - all dangling build cache 40 41 Items to be pruned will be filtered with: 42 - label!=foo=bar 43 - label!=never=remove-me 44 - label=bar=baz 45 - label=hello-world 46 - label=remove=me 47 - until=24h 48 49 Are you sure you want to continue? [y/N] ` 50 assert.Check(t, is.Equal(expected, cli.OutBuffer().String())) 51 }