aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Lemon <matt@matthewlemon.com>2020-07-29 16:13:38 +0100
committerMatthew Lemon <matt@matthewlemon.com>2020-07-29 16:13:38 +0100
commitb5bf0770b0737ee8dc1d3d9ca7f26f718beda883 (patch)
tree6ecebf2868a7faab24a8b6018260a9d523e9ebf0
parent6bdf08d2524da6f87bbc2f5128d308d058474d36 (diff)
testing all the spreadsheets now
-rw-r--r--pkg/datamaps/db_test.go58
-rw-r--r--pkg/datamaps/testdata/test_template.xlsxbin9193 -> 9397 bytes
-rw-r--r--pkg/datamaps/testdata/test_template2.xlsxbin9193 -> 9395 bytes
-rw-r--r--pkg/datamaps/testdata/test_template3.xlsxbin9193 -> 9459 bytes
4 files changed, 44 insertions, 14 deletions
diff --git a/pkg/datamaps/db_test.go b/pkg/datamaps/db_test.go
index 528ae28..d692a16 100644
--- a/pkg/datamaps/db_test.go
+++ b/pkg/datamaps/db_test.go
@@ -127,18 +127,47 @@ func TestImportSimpleTemplate(t *testing.T) {
func TestImportToDB(t *testing.T) {
var tests = []struct {
- sheet string
- cellref string
- value string
+ filename string
+ sheet string
+ cellref string
+ value string
}{
- {"Introduction", "A1", "10"},
- {"Introduction", "C9", "Test Department"},
- {"Introduction", "C22", "VUNT"},
- {"Introduction", "J9", "Greedy Parrots"},
- {"Summary", "B3", "This is a string"},
- {"Summary", "B4", "2.2"},
- {"Another Sheet", "N34", "23"},
- {"Another Sheet", "DI15", "Rabbit Helga"},
+ {"test_template.xlsm", "Introduction", "A1", "10"},
+ {"test_template.xlsm", "Introduction", "C9", "Test Department"},
+ {"test_template.xlsm", "Introduction", "C22", "VUNT"},
+ {"test_template.xlsm", "Introduction", "J9", "Greedy Parrots"},
+ {"test_template.xlsm", "Summary", "B3", "This is a string"},
+ {"test_template.xlsm", "Summary", "B4", "2.2"},
+ {"test_template.xlsm", "Another Sheet", "N34", "23"},
+ {"test_template.xlsm", "Another Sheet", "DI15", "Rabbit Helga"},
+
+ {"test_template.xlsx", "Introduction", "A1", "10"},
+ {"test_template.xlsx", "Introduction", "C9", "Test Department"},
+ {"test_template.xlsx", "Introduction", "C22", "VUNT"},
+ {"test_template.xlsx", "Introduction", "J9", "Greedy Parrots"},
+ {"test_template.xlsx", "Summary", "B3", "This is a string"},
+ {"test_template.xlsx", "Summary", "B4", "2.2"},
+ {"test_template.xlsx", "Another Sheet", "N34", "23"},
+ {"test_template.xlsx", "Another Sheet", "DI15", "Rabbit Helga"},
+
+ {"test_template2.xlsx", "Introduction", "A1", "10"},
+ {"test_template2.xlsx", "Introduction", "C9", "Test Department"},
+ {"test_template2.xlsx", "Introduction", "C22", "VUNT"},
+ {"test_template2.xlsx", "Introduction", "J9", "Greedy Parrots"},
+ {"test_template2.xlsx", "Summary", "B3", "This is a string"},
+ {"test_template2.xlsx", "Summary", "B4", "2.2"},
+ {"test_template2.xlsx", "Another Sheet", "N34", "23"},
+ {"test_template2.xlsx", "Another Sheet", "DI15", "Rabbit Helga"},
+
+ {"test_template3.xlsx", "Introduction", "A1", "10"},
+ {"test_template3.xlsx", "Introduction", "C9", "Test Department"},
+ {"test_template3.xlsx", "Introduction", "C22", "VUNT"},
+ {"test_template3.xlsx", "Introduction", "J9", "Greedy Parrots"},
+ {"test_template3.xlsx", "Summary", "B3", "This is a string"},
+ {"test_template3.xlsx", "Summary", "B4", "2.2"},
+ {"test_template3.xlsx", "Another Sheet", "N34", "23"},
+ {"test_template3.xlsx", "Another Sheet", "DI15",
+ "Printers run amok in the land of carnivores when bacchus rings 1009.ff faiioif !!!]=-=-1290909"},
}
db, err := dbSetup()
@@ -159,10 +188,10 @@ func TestImportToDB(t *testing.T) {
for _, test := range tests {
sql := fmt.Sprintf(`SELECT return_data.value FROM return_data, datamap_line
WHERE
- (return_data.filename='test_template.xlsm'
+ (return_data.filename=%q
AND datamap_line.cellref=%q
AND datamap_line.sheet=%q
- AND return_data.dml_id=datamap_line.id);`, test.cellref, test.sheet)
+ AND return_data.dml_id=datamap_line.id);`, test.filename, test.cellref, test.sheet)
got, err := exec.Command("sqlite3", opts.DBPath, sql).Output()
if err != nil {
@@ -170,7 +199,8 @@ func TestImportToDB(t *testing.T) {
}
got_s := strings.TrimSuffix(string(got), "\n")
if strings.Compare(got_s, test.value) != 0 {
- t.Errorf("we wanted %s but got %s", test.value, got_s)
+ t.Errorf("we wanted value %q in file %s sheet %s %s but got %s",
+ test.value, test.filename, test.sheet, test.cellref, got_s)
}
}
}
diff --git a/pkg/datamaps/testdata/test_template.xlsx b/pkg/datamaps/testdata/test_template.xlsx
index 77ac56f..52f6360 100644
--- a/pkg/datamaps/testdata/test_template.xlsx
+++ b/pkg/datamaps/testdata/test_template.xlsx
Binary files differ
diff --git a/pkg/datamaps/testdata/test_template2.xlsx b/pkg/datamaps/testdata/test_template2.xlsx
index 77ac56f..23513bd 100644
--- a/pkg/datamaps/testdata/test_template2.xlsx
+++ b/pkg/datamaps/testdata/test_template2.xlsx
Binary files differ
diff --git a/pkg/datamaps/testdata/test_template3.xlsx b/pkg/datamaps/testdata/test_template3.xlsx
index 77ac56f..8de40da 100644
--- a/pkg/datamaps/testdata/test_template3.xlsx
+++ b/pkg/datamaps/testdata/test_template3.xlsx
Binary files differ