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 package student_test
import ( import (
"os"
"strings" "strings"
"testing" "testing"
solutions "./solutions"
"github.com/01-edu/z01" "github.com/01-edu/z01"
) )
func TestDisplayfile(t *testing.T) { func TestDisplayfile(t *testing.T) {
var table []string
pathFileName := "./student/displayfile/quest8.txt" pathFileName := "./student/displayfile/quest8.txt"
_, err := os.Stat(pathFileName)
solutions.CheckFile(t, pathFileName) if err != nil {
t.Fatal(err)
table = append(table, "", pathFileName, "quest8.txt asdsada") }
table := []string{"", pathFileName, "quest8.txt asdsada"}
for _, s := range table { for _, s := range table {
z01.ChallengeMain(t, strings.Fields(s)...) 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