From 5f48d4d767a15be384ba7e6318556f65a750c75b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Mon, 18 May 2020 10:31:38 +0200 Subject: [PATCH] Execute test in temp folder (#1561) --- cmd/abapEnvironmentRunATCCheck_test.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/cmd/abapEnvironmentRunATCCheck_test.go b/cmd/abapEnvironmentRunATCCheck_test.go index f47a9d0376..974ec7246a 100644 --- a/cmd/abapEnvironmentRunATCCheck_test.go +++ b/cmd/abapEnvironmentRunATCCheck_test.go @@ -1,6 +1,8 @@ package cmd import ( + "io/ioutil" + "os" "testing" "github.com/stretchr/testify/assert" @@ -194,6 +196,18 @@ func TestGetResultATCRun(t *testing.T) { func TestParseATCResult(t *testing.T) { t.Run("succes case: test parsing example XML result", func(t *testing.T) { + dir, err := ioutil.TempDir("", "test get result ATC run") + if err != nil { + t.Fatal("Failed to create temporary directory") + } + oldCWD, _ := os.Getwd() + _ = os.Chdir(dir) + // clean up tmp dir + defer func() { + _ = os.Chdir(oldCWD) + _ = os.RemoveAll(dir) + }() + bodyString := ` @@ -209,7 +223,7 @@ func TestParseATCResult(t *testing.T) { ` body := []byte(bodyString) - err := parseATCResult(body) + err = parseATCResult(body) assert.Equal(t, nil, err) }) t.Run("failure case: parsing empty xml", func(t *testing.T) {