aboutsummaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
Diffstat (limited to 'pkg')
-rw-r--r--pkg/datamaps/reader.go8
-rw-r--r--pkg/datamaps/reader_test.go2
2 files changed, 6 insertions, 4 deletions
diff --git a/pkg/datamaps/reader.go b/pkg/datamaps/reader.go
index 61771c0..bb4cad7 100644
--- a/pkg/datamaps/reader.go
+++ b/pkg/datamaps/reader.go
@@ -181,12 +181,14 @@ func DMLFromDB(name string, db *sql.DB) ([]DatamapLine, error) {
return out, nil
}
-func ExtractDBDM(name string, file string, db *sql.DB) ExtractedData {
+// ExtractDBDM uses a datamap named from the database db to extract values
+// from the populated spreadsheet file file.
+func ExtractDBDM(name string, file string, db *sql.DB) (ExtractedData, error) {
xdata := ReadXLSX(file)
ddata, err := DMLFromDB(name, db) // this will need to return a []DatamapLine
if err != nil {
- log.Fatal(err)
+ return nil, err
}
names := getSheetNames(ddata)
@@ -203,7 +205,7 @@ func ExtractDBDM(name string, file string, db *sql.DB) ExtractedData {
}
}
- return outer
+ return outer, nil
}
//Extract returns the file's data as a map,
diff --git a/pkg/datamaps/reader_test.go b/pkg/datamaps/reader_test.go
index de169dd..af804f6 100644
--- a/pkg/datamaps/reader_test.go
+++ b/pkg/datamaps/reader_test.go
@@ -158,7 +158,7 @@ func TestExtractUsingDBDM(t *testing.T) {
t.Errorf("Unable to write datamap to database file because %v.", err)
}
- d := ExtractDBDM("First Datamap", "testdata/test_template.xlsx", db)
+ d, _ := ExtractDBDM("First Datamap", "testdata/test_template.xlsx", db)
cases := []struct {
sheet, cellref, val string
}{