func TestDeletingImagePruner(t *testing.T) { flag.Lookup("v").Value.Set(fmt.Sprint(*logLevel)) tests := map[string]struct { imageDeletionError error }{ "no error": {}, "delete error": { imageDeletionError: fmt.Errorf("foo"), }, } for name, test := range tests { imageClient := testclient.Fake{} imageClient.AddReactor("delete", "images", func(action ktc.Action) (handled bool, ret runtime.Object, err error) { return true, nil, test.imageDeletionError }) imagePruner := NewDeletingImagePruner(imageClient.Images()) err := imagePruner.PruneImage(&imageapi.Image{ObjectMeta: kapi.ObjectMeta{Name: "id2"}}) if test.imageDeletionError != nil { if e, a := test.imageDeletionError, err; e != a { t.Errorf("%s: err: expected %v, got %v", name, e, a) } continue } if e, a := 1, len(imageClient.Actions()); e != a { t.Errorf("%s: expected %d actions, got %d: %#v", name, e, a, imageClient.Actions()) continue } if !imageClient.Actions()[0].Matches("delete", "images") { t.Errorf("%s: expected action %s, got %v", name, "delete-images", imageClient.Actions()[0]) } } }