Skip to content

Commit

Permalink
Execute test in temp folder (#1561)
Browse files Browse the repository at this point in the history
  • Loading branch information
stippi2 authored May 18, 2020
1 parent 00149b2 commit 5f48d4d
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion cmd/abapEnvironmentRunATCCheck_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package cmd

import (
"io/ioutil"
"os"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -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 := `<?xml version="1.0" encoding="UTF-8"?>
<checkstyle>
<file name="testFile">
Expand All @@ -209,7 +223,7 @@ func TestParseATCResult(t *testing.T) {
</checkstyle>`
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) {
Expand Down

0 comments on commit 5f48d4d

Please sign in to comment.