From 9835833c0d1fc3c59c0619cc4cda5359ddba3a4c Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Thu, 14 Nov 2019 20:14:07 +0000 Subject: fixed - passing test --- reader/reader.go | 6 ++---- reader/reader_test.go | 6 ++++++ reader/testdata/datamap.csv | 2 ++ reader/testdata/test_template.xlsx | Bin 9039 -> 9221 bytes 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/reader/reader.go b/reader/reader.go index 71870c5..55966af 100644 --- a/reader/reader.go +++ b/reader/reader.go @@ -173,14 +173,12 @@ func Extract(dm string, ssheet string) ExtractedData { sheetNames := getSheetNames(dmlData) output := make(ExtractedData, len(sheetNames)) + inner := make(map[string]xlsx.Cell) + for _, i := range dmlData { sheet := i.Sheet cellref := i.Cellref if val, ok := data[sheet][cellref]; ok { - // TODO check what is happening here... - // ddg "golang assingment to entry in nil map" - // first SO entry, but I don't think I totally understand - inner := make(map[string]xlsx.Cell) inner[cellref] = *val.Cell output[sheet] = inner } diff --git a/reader/reader_test.go b/reader/reader_test.go index 3096c1b..eab6848 100644 --- a/reader/reader_test.go +++ b/reader/reader_test.go @@ -104,4 +104,10 @@ func TestExtract(t *testing.T) { if d["Introduction"]["C9"].Value != "Test Department" { t.Errorf("Expected C9 in Introduction sheet to be Test Department - instead it is %s", d["Introduction"]["C9"].Value) } + if d["Introduction"]["J9"].Value != "Greedy Parrots" { + t.Errorf("Expected J9 in Introduction sheet to be Greedy Parrots - instead it is %s", d["Introduction"]["J9"].Value) + } + if d["Introduction"]["A1"].Value != "10" { + t.Errorf("Expected A1 in Introduction sheet to be 10 - instead it is %s", d["Introduction"]["A1"].Value) + } } diff --git a/reader/testdata/datamap.csv b/reader/testdata/datamap.csv index d89db75..d1f3866 100644 --- a/reader/testdata/datamap.csv +++ b/reader/testdata/datamap.csv @@ -4,6 +4,8 @@ Department ,Introduction,C9 Delivery Body ,Introduction,C10 DRRDD - IPA ID Number,Introduction,C12 Controls Project ID number,Introduction,C13 +Jokey Entry,Introduction,A1 +Parrots Name,Introduction,J9 Project Type (for IPA use),Introduction,C14 Classification,Introduction,C15 DRRDD (GMPP - formally joined GMPP),Introduction,C16 diff --git a/reader/testdata/test_template.xlsx b/reader/testdata/test_template.xlsx index 5e2ea97..97ddf63 100644 Binary files a/reader/testdata/test_template.xlsx and b/reader/testdata/test_template.xlsx differ -- cgit v1.2.3