From 010bca6323e91ed9984b95d21fa824bad382dc31 Mon Sep 17 00:00:00 2001 From: guangxuli Date: Wed, 28 Sep 2016 16:52:55 +0800 Subject: [PATCH] if test succ remove the tmp file --- pkg/kubectl/cmd/util/helpers_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/kubectl/cmd/util/helpers_test.go b/pkg/kubectl/cmd/util/helpers_test.go index 43a2bffd4fe..9f33b1dfc51 100644 --- a/pkg/kubectl/cmd/util/helpers_test.go +++ b/pkg/kubectl/cmd/util/helpers_test.go @@ -20,6 +20,7 @@ import ( "fmt" "io/ioutil" "net/http" + "os" "reflect" "strings" "syscall" @@ -308,6 +309,11 @@ func TestDumpReaderToFile(t *testing.T) { } defer syscall.Unlink(tempFile.Name()) defer tempFile.Close() + defer func() { + if !t.Failed() { + os.Remove(tempFile.Name()) + } + }() err = DumpReaderToFile(strings.NewReader(testString), tempFile.Name()) if err != nil { t.Errorf("error in DumpReaderToFile: %v", err)