Skip to content

Commit cebe2d2

Browse files
Add the cleaning to the tests
1 parent 52c5fa8 commit cebe2d2

3 files changed

Lines changed: 7 additions & 0 deletions

File tree

check_imports_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package coderunner
22

33
import (
4+
"os"
5+
"path/filepath"
46
"testing"
57

68
mapset "github.com/deckarep/golang-set"
@@ -80,6 +82,7 @@ func TestCheckImports(test *testing.T) {
8082
test.Run(data.name, func(test *testing.T) {
8183
pathToCode, err := systemutils.SaveTemporaryText(data.args.code, ".go")
8284
require.NoError(test, err)
85+
defer os.RemoveAll(filepath.Dir(pathToCode)) // nolint: errcheck
8386

8487
receivedErr := CheckImports(pathToCode, data.args.allowedImports)
8588

compile_code_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package coderunner
33
import (
44
"context"
55
"io/ioutil"
6+
"os"
7+
"path/filepath"
68
"testing"
79

810
mapset "github.com/deckarep/golang-set"
@@ -142,6 +144,7 @@ func TestCompileCode(test *testing.T) {
142144
test.Run(data.name, func(test *testing.T) {
143145
pathToCode, err := systemutils.SaveTemporaryText(data.args.code, ".go")
144146
require.NoError(test, err)
147+
defer os.RemoveAll(filepath.Dir(pathToCode)) // nolint: errcheck
145148

146149
pathToExecutable, receivedErr :=
147150
CompileCode(data.args.ctx, pathToCode, data.args.allowedImports)

system-utils/save_temporary_text_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
func TestSaveTemporaryText(test *testing.T) {
1414
path, err := SaveTemporaryText("test", ".txt")
1515
require.NoError(test, err)
16+
defer os.RemoveAll(filepath.Dir(path)) // nolint: errcheck
1617

1718
content, err := ioutil.ReadFile(path)
1819
require.NoError(test, err)

0 commit comments

Comments
 (0)