Browse Source

Refactor displayfile solution

content-update
Xavier Petit 4 years ago committed by xpetit
parent
commit
b8c496ad89
  1. 13
      tests/go/displayfile_test.go
  2. 15
      tests/go/solutions/checkfile.go

13
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)...)
}

15
tests/go/solutions/checkfile.go

@ -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())
}
}
Loading…
Cancel
Save