diff options
Diffstat (limited to 'pkg/datamaps')
-rw-r--r-- | pkg/datamaps/reader.go | 9 | ||||
-rw-r--r-- | pkg/datamaps/reader_test.go | 4 |
2 files changed, 10 insertions, 3 deletions
diff --git a/pkg/datamaps/reader.go b/pkg/datamaps/reader.go index ef4ef1a..050853a 100644 --- a/pkg/datamaps/reader.go +++ b/pkg/datamaps/reader.go @@ -149,6 +149,8 @@ func ReadXLSX(ssheet string) FileData { func DMLFromDB(name string, db *sql.DB) []DatamapLine { + var out []DatamapLine + query := ` select key, sheet, cellref @@ -170,9 +172,12 @@ func DMLFromDB(name string, db *sql.DB) []DatamapLine { if err := rows.Scan(&key, &sheet, &cellref); err != nil { log.Fatal(err) } - log.Printf("key %s\nsheet %s\ncellref %v", key, sheet, cellref) + + // log.Printf("key %s\nsheet %s\ncellref %v", key, sheet, cellref) + out = append(out, DatamapLine{Key: key, Sheet: sheet, Cellref: cellref}) } - return make([]DatamapLine, 0) + + return out } // func ExtractDBDM(name string, file string) ExtractedData { diff --git a/pkg/datamaps/reader_test.go b/pkg/datamaps/reader_test.go index be89e5f..35046cc 100644 --- a/pkg/datamaps/reader_test.go +++ b/pkg/datamaps/reader_test.go @@ -111,7 +111,9 @@ func TestDMLSliceFromDatabase(t *testing.T) { t.Errorf("Unable to write datamap to database file because %v.", err) } data := DMLFromDB("First Datamap", db) - t.Log(data) + if data[0].Key != "Project/Programme Name" { + t.Errorf("expected to see Project/Programme Name and got %q\n", data[0]) + } } func TestExtract(t *testing.T) { |