aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/dbasik-api/datamaps_test.go
blob: 428f301219720fb0ead9d3c364cc881996545feb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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)
	}
}