diff options
author | Matthew Lemon <matt@matthewlemon.com> | 2020-07-27 08:16:48 +0100 |
---|---|---|
committer | Matthew Lemon <matt@matthewlemon.com> | 2020-07-27 08:16:48 +0100 |
commit | 7d62c9811c2f4a8af3eddd53da730973107e5900 (patch) | |
tree | fb99327870ddc38c3d48c786f92ba1ea6d097003 /pkg/datamaps/reader_test.go | |
parent | bde5adb96e699a6ef5d7c473b0bd2c29f305c663 (diff) |
testing func to get xlsx files from dir
Diffstat (limited to 'pkg/datamaps/reader_test.go')
-rw-r--r-- | pkg/datamaps/reader_test.go | 64 |
1 files changed, 34 insertions, 30 deletions
diff --git a/pkg/datamaps/reader_test.go b/pkg/datamaps/reader_test.go index 53aff4a..abe5afc 100644 --- a/pkg/datamaps/reader_test.go +++ b/pkg/datamaps/reader_test.go @@ -2,6 +2,7 @@ package datamaps import ( "os" + "reflect" "testing" ) @@ -217,33 +218,36 @@ func TestExtract(t *testing.T) { } } -// func TestgetTargetFiles(t *testing.T) { -// // This is not a suitable test for parameterisation, but doing it this way anyway. -// type args struct { -// path string -// } -// 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, -// }, -// } -// 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) -// } -// }) -// } -// } +func TestGetTargetFiles(t *testing.T) { + // This is not a suitable test for parameterisation, but doing it this way anyway. + type args struct { + path string + } + tests := []struct { + name string + args args + want []string + wantErr bool + }{ + {"Get files in testdata", + args{"./testdata/"}, + []string{"testdata/test_template.xlsx", + "testdata/test_template2.xlsx", + "testdata/test_template3.xlsx"}, + false, + }, + } + for _, tt := range tests { + t.Log("Running the test") + 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) + } + }) + } +} |