@@ -73,13 +73,15 @@ func TestVolumePruneSuccess(t *testing.T) {
7373 testCases := []struct {
7474 name string
7575 args []string
76+ input string
7677 volumePruneFunc func (args filters.Args ) (types.VolumesPruneReport , error )
7778 }{
7879 {
79- name : "all" ,
80- args : []string {"--all" },
80+ name : "all" ,
81+ args : []string {"--all" },
82+ input : "y" ,
8183 volumePruneFunc : func (pruneFilter filters.Args ) (types.VolumesPruneReport , error ) {
82- assert .Check (t , is .Equal ([]string {"true" }, pruneFilter .Get ("all" )))
84+ assert .Check (t , is .DeepEqual ([]string {"true" }, pruneFilter .Get ("all" )))
8385 return types.VolumesPruneReport {}, nil
8486 },
8587 },
@@ -91,10 +93,11 @@ func TestVolumePruneSuccess(t *testing.T) {
9193 },
9294 },
9395 {
94- name : "label-filter" ,
95- args : []string {"--filter" , "label=foobar" },
96+ name : "label-filter" ,
97+ args : []string {"--filter" , "label=foobar" },
98+ input : "y" ,
9699 volumePruneFunc : func (pruneFilter filters.Args ) (types.VolumesPruneReport , error ) {
97- assert .Check (t , is .Equal ([]string {"foobar" }, pruneFilter .Get ("label" )))
100+ assert .Check (t , is .DeepEqual ([]string {"foobar" }, pruneFilter .Get ("label" )))
98101 return types.VolumesPruneReport {}, nil
99102 },
100103 },
@@ -104,6 +107,9 @@ func TestVolumePruneSuccess(t *testing.T) {
104107 t .Run (tc .name , func (t * testing.T ) {
105108 cli := test .NewFakeCli (& fakeClient {volumePruneFunc : tc .volumePruneFunc })
106109 cmd := NewPruneCommand (cli )
110+ if tc .input != "" {
111+ cli .SetIn (streams .NewIn (io .NopCloser (strings .NewReader (tc .input ))))
112+ }
107113 cmd .SetOut (io .Discard )
108114 cmd .SetArgs (tc .args )
109115 err := cmd .Execute ()
0 commit comments