From 85393a60c200b9c7429af84360ec9f58374e6b5e Mon Sep 17 00:00:00 2001 From: Priya Wadhwa Date: Wed, 29 Aug 2018 16:11:03 -0700 Subject: [PATCH] Fixed unit tests --- pkg/util/fs_util.go | 14 ----------- pkg/util/fs_util_test.go | 52 ---------------------------------------- 2 files changed, 66 deletions(-) diff --git a/pkg/util/fs_util.go b/pkg/util/fs_util.go index b63a41111..0c020bdb5 100644 --- a/pkg/util/fs_util.go +++ b/pkg/util/fs_util.go @@ -247,20 +247,6 @@ func extractFile(dest string, hdr *tar.Header, tr io.Reader) error { return nil } -func checkWhiteouts(path string, whiteouts map[string]struct{}) bool { - // Don't add the file if it or it's directory are whited out. - if _, ok := whiteouts[path]; ok { - return true - } - for wd := range whiteouts { - if HasFilepathPrefix(path, wd) { - logrus.Infof("Not adding %s because it's directory is whited out", path) - return true - } - } - return false -} - func CheckWhitelist(path string) (bool, error) { abs, err := filepath.Abs(path) if err != nil { diff --git a/pkg/util/fs_util_test.go b/pkg/util/fs_util_test.go index 3810f5d55..5bfb1a403 100644 --- a/pkg/util/fs_util_test.go +++ b/pkg/util/fs_util_test.go @@ -164,58 +164,6 @@ func Test_ParentDirectories(t *testing.T) { } } -func Test_checkWhiteouts(t *testing.T) { - type args struct { - path string - whiteouts map[string]struct{} - } - tests := []struct { - name string - args args - want bool - }{ - { - name: "file whited out", - args: args{ - path: "/foo", - whiteouts: map[string]struct{}{"/foo": {}}, - }, - want: true, - }, - { - name: "directory whited out", - args: args{ - path: "/foo/bar", - whiteouts: map[string]struct{}{"/foo": {}}, - }, - want: true, - }, - { - name: "grandparent whited out", - args: args{ - path: "/foo/bar/baz", - whiteouts: map[string]struct{}{"/foo": {}}, - }, - want: true, - }, - { - name: "sibling whited out", - args: args{ - path: "/foo/bar/baz", - whiteouts: map[string]struct{}{"/foo/bat": {}}, - }, - want: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := checkWhiteouts(tt.args.path, tt.args.whiteouts); got != tt.want { - t.Errorf("checkWhiteouts() = %v, want %v", got, tt.want) - } - }) - } -} - func Test_CheckWhitelist(t *testing.T) { type args struct { path string