From b8c496ad8944604aa1925f8e510243d26f8ea194 Mon Sep 17 00:00:00 2001 From: Xavier Petit <32063953+xpetit@users.noreply.github.com> Date: Mon, 13 Apr 2020 19:10:31 +0200 Subject: [PATCH] Refactor displayfile solution --- tests/go/displayfile_test.go | 13 ++++++------- tests/go/solutions/checkfile.go | 15 --------------- 2 files changed, 6 insertions(+), 22 deletions(-) delete mode 100644 tests/go/solutions/checkfile.go diff --git a/tests/go/displayfile_test.go b/tests/go/displayfile_test.go index c6c35e4f8..f4dd57f5e 100644 --- a/tests/go/displayfile_test.go +++ b/tests/go/displayfile_test.go @@ -1,21 +1,20 @@ package student_test import ( + "os" "strings" "testing" - solutions "./solutions" "github.com/01-edu/z01" ) func TestDisplayfile(t *testing.T) { - var table []string pathFileName := "./student/displayfile/quest8.txt" - - solutions.CheckFile(t, pathFileName) - - table = append(table, "", pathFileName, "quest8.txt asdsada") - + _, err := os.Stat(pathFileName) + if err != nil { + t.Fatal(err) + } + table := []string{"", pathFileName, "quest8.txt asdsada"} for _, s := range table { z01.ChallengeMain(t, strings.Fields(s)...) } diff --git a/tests/go/solutions/checkfile.go b/tests/go/solutions/checkfile.go deleted file mode 100644 index 8b40afff7..000000000 --- a/tests/go/solutions/checkfile.go +++ /dev/null @@ -1,15 +0,0 @@ -package solutions - -import ( - "os" - "testing" -) - -//function to check if the file exists in a given path -func CheckFile(t *testing.T, path string) { - _, err := os.Stat(path) - - if err != nil { - t.Fatalf(err.Error()) - } -}