aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/datamaps/db_test.go
diff options
context:
space:
mode:
authorMatthew Lemon <matt@matthewlemon.com>2020-07-24 10:12:01 +0100
committerMatthew Lemon <matt@matthewlemon.com>2020-07-24 10:12:01 +0100
commit36f3983b039905c54a957f236e4a9718ea7c918f (patch)
tree46c5424ed0930a7dfbf54ca0f77d05924fc96f01 /pkg/datamaps/db_test.go
parent3b82b7463987ff637530cb403b6d294978bbd115 (diff)
mostly linting
Diffstat (limited to '')
-rw-r--r--pkg/datamaps/db_test.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/pkg/datamaps/db_test.go b/pkg/datamaps/db_test.go
index a9988d1..4d2179f 100644
--- a/pkg/datamaps/db_test.go
+++ b/pkg/datamaps/db_test.go
@@ -7,19 +7,26 @@ import (
func TestOpenSQLiteFile(t *testing.T) {
db, err := SetupDB("./testdata/test.db")
defer db.Close()
+
if err != nil {
t.Fatal("Expected to be able to set up the database.")
}
+
stmt := `insert into datamap(id, name) values(1,'cock')`
_, err = db.Exec(stmt)
+
if err != nil {
t.Errorf("Cannot add record to db")
}
+
rows, err := db.Query("select name from datamap")
+
if err != nil {
t.Errorf("Cannot run select statement")
}
+
defer rows.Close()
+
for rows.Next() {
var name string
err = rows.Scan(&name)
@@ -32,14 +39,17 @@ func TestOpenSQLiteFile(t *testing.T) {
func TestDatamapGoesIntoDB(t *testing.T) {
db, err := SetupDB("./testdata/test.db")
defer db.Close()
+
if err != nil {
t.Fatal("Expected to be able to set up the database.")
}
+
opts := Options{
DBPath: "./testdata/test.db",
DMName: "First Datamap",
DMPath: "./testdata/datamap.csv",
}
+
if err := DatamapToDB(&opts); err != nil {
t.Errorf("Unable to write datamap to database file because %v.", err)
}