aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/db
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--pkg/db/setup.go7
-rw-r--r--pkg/db/setup_test.go13
-rw-r--r--pkg/db/testdata/test.dbbin135168 -> 135168 bytes
3 files changed, 14 insertions, 6 deletions
diff --git a/pkg/db/setup.go b/pkg/db/setup.go
index ef53cf6..d0c0064 100644
--- a/pkg/db/setup.go
+++ b/pkg/db/setup.go
@@ -49,7 +49,12 @@ func SetupDB(path string) (*sql.DB, error) {
}
//DatamapToDB takes a slice of DatamapLine and writes it to a sqlite3 db file.
-func DatamapToDB(data []reader.DatamapLine, db *sql.DB, dm_name string) error {
+func DatamapToDB(data []reader.DatamapLine, dm_name string, dm_path string) error {
+ log.Printf("Importing Datamap")
+ db, err := SetupDB("/home/lemon/.config/datamaps-go/datamaps.db")
+ if err != nil {
+ return err
+ }
tx, err := db.Begin()
if err != nil {
return err
diff --git a/pkg/db/setup_test.go b/pkg/db/setup_test.go
index 3787d2e..a8868ed 100644
--- a/pkg/db/setup_test.go
+++ b/pkg/db/setup_test.go
@@ -54,13 +54,16 @@ func TestOpenSQLiteFile(t *testing.T) {
// tx.Commit()
func TestDatamapGoesIntoDB(t *testing.T) {
- db, err := SetupDB("./testdata/test.db") // we set up, then just open it.
- defer db.Close()
+ // db, err := SetupDB("./testdata/test.db") // we set up, then just open it.
+ // defer db.Close()
+ // if err != nil {
+ // t.Fatal("Expected to be able to set up the database.")
+ // }
+ d, err := reader.ReadDML("./testdata/datamap.csv")
if err != nil {
- t.Fatal("Expected to be able to set up the database.")
+ t.Fatal(err)
}
- d, _ := reader.ReadDML("./testdata/datamap.csv")
- err = DatamapToDB(d, db, "First Datamap")
+ err = DatamapToDB(d, "First Datamap", "./testdata/test.db")
if err != nil {
t.Errorf("Unable to write datamap to database file because %v.", err)
}
diff --git a/pkg/db/testdata/test.db b/pkg/db/testdata/test.db
index 81de353..a85f6ec 100644
--- a/pkg/db/testdata/test.db
+++ b/pkg/db/testdata/test.db
Binary files differ