diff options
Diffstat (limited to '')
-rw-r--r-- | pkg/datamaps/db.go | 4 | ||||
-rw-r--r-- | pkg/datamaps/db_test.go | 2 | ||||
-rw-r--r-- | pkg/datamaps/reader_test.go | 4 | ||||
-rw-r--r-- | pkg/datamaps/testdata/short/.~lock.datamap_matches_test_template.csv# | 1 | ||||
-rw-r--r-- | pkg/datamaps/testdata/short/datamap_matches_test_template.csv (renamed from pkg/datamaps/testdata/datamap_matches_test_template.csv) | 1 | ||||
-rw-r--r-- | pkg/datamaps/testdata/short/test_template.xlsm | bin | 0 -> 9193 bytes | |||
-rw-r--r-- | pkg/datamaps/testdata/test_template.xlsx | bin | 0 -> 9193 bytes | |||
-rw-r--r-- | pkg/datamaps/testdata/test_template2.xlsx | bin | 0 -> 9193 bytes | |||
-rw-r--r-- | pkg/datamaps/testdata/test_template3.xlsx | bin | 0 -> 9193 bytes |
9 files changed, 8 insertions, 4 deletions
diff --git a/pkg/datamaps/db.go b/pkg/datamaps/db.go index 9eac466..2d675a6 100644 --- a/pkg/datamaps/db.go +++ b/pkg/datamaps/db.go @@ -55,7 +55,9 @@ func setupDB(path string) (*sql.DB, error) { ON DELETE CASCADE ); ` - os.Create(path) + if _, err := os.Create(path); err != nil { + return nil, err + } db, err := sql.Open("sqlite3", path) if err != nil { return db, errors.New("Cannot open that damn database file") diff --git a/pkg/datamaps/db_test.go b/pkg/datamaps/db_test.go index 3ca9054..93f3a39 100644 --- a/pkg/datamaps/db_test.go +++ b/pkg/datamaps/db_test.go @@ -13,7 +13,7 @@ func TestOpenSQLiteFile(t *testing.T) { }() if err != nil { - t.Fatal("Expected to be able to set up the database.") + t.Fatalf("%v\ndatamaps-log: Expected to be able to set up the database.", err) } stmt := `insert into datamap(id, name) values(1,'cock')` diff --git a/pkg/datamaps/reader_test.go b/pkg/datamaps/reader_test.go index 32e7f67..f784834 100644 --- a/pkg/datamaps/reader_test.go +++ b/pkg/datamaps/reader_test.go @@ -162,7 +162,7 @@ func TestExtractUsingDBDM(t *testing.T) { opts := Options{ DBPath: "./testdata/test.db", DMName: "First Datamap", - DMPath: "./testdata/datamap.csv", + DMPath: "./testdata/short/datamap_matches_test_template.csv", } if err := DatamapToDB(&opts); err != nil { @@ -182,7 +182,7 @@ func TestExtractUsingDBDM(t *testing.T) { for _, c := range cases { got := d[c.sheet][c.cellref].Value if got != c.val { - t.Errorf("The test expected %s in %s sheet to be %s "+ + t.Errorf("test_template.xlsx: The test expected %s in %s sheet to be %s "+ "- instead it is %s.", c.sheet, c.cellref, c.val, d[c.sheet][c.cellref].Value) } diff --git a/pkg/datamaps/testdata/short/.~lock.datamap_matches_test_template.csv# b/pkg/datamaps/testdata/short/.~lock.datamap_matches_test_template.csv# new file mode 100644 index 0000000..3609925 --- /dev/null +++ b/pkg/datamaps/testdata/short/.~lock.datamap_matches_test_template.csv# @@ -0,0 +1 @@ +,lemon,x201.lan,28.07.2020 07:18,file:///home/lemon/.config/libreoffice/4;
\ No newline at end of file diff --git a/pkg/datamaps/testdata/datamap_matches_test_template.csv b/pkg/datamaps/testdata/short/datamap_matches_test_template.csv index 553828d..f9e94e9 100644 --- a/pkg/datamaps/testdata/datamap_matches_test_template.csv +++ b/pkg/datamaps/testdata/short/datamap_matches_test_template.csv @@ -3,3 +3,4 @@ A Ten,Introduction,A1 A Test,Introduction,C9 A Vunt,Introduction,C22 Floaty,Another Sheet,D5 +A Parrot,Introduction,J9 diff --git a/pkg/datamaps/testdata/short/test_template.xlsm b/pkg/datamaps/testdata/short/test_template.xlsm Binary files differnew file mode 100644 index 0000000..77ac56f --- /dev/null +++ b/pkg/datamaps/testdata/short/test_template.xlsm diff --git a/pkg/datamaps/testdata/test_template.xlsx b/pkg/datamaps/testdata/test_template.xlsx Binary files differnew file mode 100644 index 0000000..77ac56f --- /dev/null +++ b/pkg/datamaps/testdata/test_template.xlsx diff --git a/pkg/datamaps/testdata/test_template2.xlsx b/pkg/datamaps/testdata/test_template2.xlsx Binary files differnew file mode 100644 index 0000000..77ac56f --- /dev/null +++ b/pkg/datamaps/testdata/test_template2.xlsx diff --git a/pkg/datamaps/testdata/test_template3.xlsx b/pkg/datamaps/testdata/test_template3.xlsx Binary files differnew file mode 100644 index 0000000..77ac56f --- /dev/null +++ b/pkg/datamaps/testdata/test_template3.xlsx |