fix tests

This commit is contained in:
Tejal Desai 2020-03-24 10:50:59 -07:00
parent ffc372a63b
commit caaf6c8adf
3 changed files with 10 additions and 3 deletions

View File

@ -371,10 +371,15 @@ func Test_filesToSave(t *testing.T) {
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
tmpDir, err := ioutil.TempDir("", "") tmpDir, err := ioutil.TempDir("", "")
original := config.RootDir
config.RootDir = tmpDir
if err != nil { if err != nil {
t.Errorf("error creating tmpdir: %s", err) t.Errorf("error creating tmpdir: %s", err)
} }
defer os.RemoveAll(tmpDir) defer func () {
config.RootDir = original
os.RemoveAll(tmpDir)
}()
for _, f := range tt.files { for _, f := range tt.files {
p := filepath.Join(tmpDir, f) p := filepath.Join(tmpDir, f)

View File

@ -25,6 +25,7 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/GoogleContainerTools/kaniko/pkg/config"
"github.com/GoogleContainerTools/kaniko/pkg/util" "github.com/GoogleContainerTools/kaniko/pkg/util"
"github.com/GoogleContainerTools/kaniko/testutil" "github.com/GoogleContainerTools/kaniko/testutil"
"github.com/pkg/errors" "github.com/pkg/errors"
@ -159,7 +160,6 @@ func TestSnapshotFSChangePermissions(t *testing.T) {
if err == io.EOF { if err == io.EOF {
break break
} }
t.Logf("Info %s in tar", hdr.Name)
foundFiles = append(foundFiles, hdr.Name) foundFiles = append(foundFiles, hdr.Name)
if _, isFile := snapshotFiles[hdr.Name]; !isFile { if _, isFile := snapshotFiles[hdr.Name]; !isFile {
t.Fatalf("File %s unexpectedly in tar", hdr.Name) t.Fatalf("File %s unexpectedly in tar", hdr.Name)
@ -458,8 +458,11 @@ func setUpTest() (string, *Snapshotter, func(), error) {
return "", nil, nil, errors.Wrap(err, "initializing snapshotter") return "", nil, nil, errors.Wrap(err, "initializing snapshotter")
} }
original := config.KanikoDir
config.KanikoDir = testDir
cleanup := func() { cleanup := func() {
os.RemoveAll(snapshotPath) os.RemoveAll(snapshotPath)
config.KanikoDir = original
dirCleanUp() dirCleanUp()
} }

View File

@ -131,7 +131,6 @@ func ResolveSources(srcs []string, root string) ([]string, error) {
return nil, errors.Wrap(err, "matching sources") return nil, errors.Wrap(err, "matching sources")
} }
logrus.Debugf("Resolved sources to %v", resolved) logrus.Debugf("Resolved sources to %v", resolved)
fmt.Println("end of resolve sources")
return resolved, nil return resolved, nil
} }