aboutsummaryrefslogtreecommitdiffstats
path: root/reader/reader_test.go
diff options
context:
space:
mode:
authorMatthew Lemon <lemon@matthewlemon.com>2019-12-06 16:55:53 +0000
committerMatthew Lemon <lemon@matthewlemon.com>2019-12-06 16:55:53 +0000
commit52240ba3b5861a2636cfd86f352349717fbf1af2 (patch)
tree3b5efcef8a5c0d7a214879c59dfdb224c2094024 /reader/reader_test.go
parente6ea4065fe5b46fb41ba027fe7344c4ff1a5f2b9 (diff)
rewrote a test unnecessarily, but did it anyway
Diffstat (limited to 'reader/reader_test.go')
-rw-r--r--reader/reader_test.go39
1 files changed, 26 insertions, 13 deletions
diff --git a/reader/reader_test.go b/reader/reader_test.go
index d6d29fb..29d08e0 100644
--- a/reader/reader_test.go
+++ b/reader/reader_test.go
@@ -1,7 +1,7 @@
package reader
import (
- "strings"
+ "reflect"
"testing"
)
@@ -89,19 +89,32 @@ func TestExtract(t *testing.T) {
}
func TestGetTargetFiles(t *testing.T) {
- path := "/home/lemon/go/src/github.com/hammerheadlemon/datamaps-go/reader/testdata/"
- files, err := GetTargetFiles(path)
- if err != nil {
- t.Error(err)
+ // This is not a suitable test for parameterisation, but doing it this way anyway.
+ type args struct {
+ path string
}
- found := false
- for _, f := range files {
- if strings.Contains(f, "test_template.xlsx") {
- found = true
- break
- }
+ tests := []struct {
+ name string
+ args args
+ want []string
+ wantErr bool
+ }{
+ {"TestGetTargetFiles",
+ args{"/home/lemon/go/src/github.com/hammerheadlemon/datamaps-go/reader/testdata/"},
+ []string{"/home/lemon/go/src/github.com/hammerheadlemon/datamaps-go/reader/testdata/test_template.xlsx"},
+ false,
+ },
}
- if found == false {
- t.Errorf("test_template.xlsx not found - and it is there!")
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ got, err := GetTargetFiles(tt.args.path)
+ if (err != nil) != tt.wantErr {
+ t.Errorf("GetTargetFiles() error = %v, wantErr %v", err, tt.wantErr)
+ return
+ }
+ if !reflect.DeepEqual(got, tt.want) {
+ t.Errorf("GetTargetFiles() = %v, want %v", got, tt.want)
+ }
+ })
}
}