diff options
Diffstat (limited to 'cmd/dbasik-api/datamaps_test.go')
-rw-r--r-- | cmd/dbasik-api/datamaps_test.go | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/cmd/dbasik-api/datamaps_test.go b/cmd/dbasik-api/datamaps_test.go new file mode 100644 index 0000000..428f301 --- /dev/null +++ b/cmd/dbasik-api/datamaps_test.go @@ -0,0 +1,50 @@ +package main + +import ( + "slices" + "testing" + "time" +) + +func TestReadDML(t *testing.T) { + dm := datamap{ + ID: 0, + Name: "Test Name", + Description: "Test description", + Created: time.Now(), + DMLs: []datamapLine{ + { + ID: 1, + Key: "Test Key", + Sheet: "Test Sheet", + DataType: "TEXT", + Cellref: "A10", + }, + { + ID: 2, + Key: "Test Key 2", + Sheet: "Test Sheet", + DataType: "TEXT", + Cellref: "A11", + }, + { + ID: 3, + Key: "Test Key 3", + Sheet: "Test Sheet 2", + DataType: "TEXT", + Cellref: "A12", + }, + }, + } + + got := GetSheetsFromDM(dm) + if !slices.Contains(got, "Test Sheet") { + t.Errorf("expected to find Test Sheet in %v but didn't find it", got) + } + if !slices.Contains(got, "Test Sheet 2") { + t.Errorf("expected to find Test Sheet in %v but didn't find it", got) + } + if slices.Contains(got, "Test Sheet 3") { + t.Errorf("expected to find Test Sheet in %v but didn't find it", got) + } +} |