diff options
author | Matthew Lemon <lemon@matthewlemon.com> | 2019-11-15 20:48:49 +0000 |
---|---|---|
committer | Matthew Lemon <lemon@matthewlemon.com> | 2019-11-15 20:48:49 +0000 |
commit | 6cf0f37a2434257808ae24de75349fe1b902f136 (patch) | |
tree | 0eb09ab2994288cf2b417af28c9286b63f263aa1 /reader/reader_test.go | |
parent | 092fc3b78fff55cd9d53d4353fb3d4523393f11e (diff) |
another test parameterized
Diffstat (limited to 'reader/reader_test.go')
-rw-r--r-- | reader/reader_test.go | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/reader/reader_test.go b/reader/reader_test.go index 3a30fa7..3b82e24 100644 --- a/reader/reader_test.go +++ b/reader/reader_test.go @@ -6,19 +6,18 @@ import ( func TestReadDML(t *testing.T) { d, _ := ReadDML("testdata/datamap.csv") - // Test Key values - if d[0].Key != "Project/Programme Name" { - t.Errorf("d[0].Key = %s; want Project/Programme Name", d[0].Key) - } - if d[1].Key != "Department" { - t.Errorf("d[1].Key = %s; want Department (without a space)", d[1].Key) - } - if d[2].Key != "Delivery Body" { - t.Errorf("d[2].Key = %s; want Delivery Body (without a space)", d[2].Key) + cases := []struct { + idx int + val string + }{ + {0, "Project/Programme Name"}, + {1, "Department"}, + {2, "Delivery Body"}, } - // Test Sheet values - if d[0].Sheet != "Introduction" { - t.Errorf("d[0].Sheet = %s; want Introduction", d[0].Key) + for _, c := range cases { + if got := d[c.idx].Key; got != c.val { + t.Errorf("Expected %s, got %s", c.val, d[c.idx].Key) + } } } |