aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/dbasik-api/datamaps_test.go
blob: 827a054880acc8a74f55212fbb992f4bc4f61500 (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
51
52
53
54
55
56
57
58
package main

import (
	"slices"
	"testing"
	"time"
)

func TestGetSheetsFromDM(t *testing.T) {
	testCases := []struct {
		name     string
		datamap  Datamap
		expected []string
	}{
		{
			name: "Extract unique sheet names",
			datamap: 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",
					},
				},
			},
			expected: []string{"Test Sheet", "Test Sheet 2"},
		},
	}

	for _, tc := range testCases {
		t.Run(tc.name, func(t *testing.T) {
			got := GetSheetsFromDM(tc.datamap)
			if !slices.Equal(got, tc.expected) {
				t.Errorf("GetSheetsFromDM(%v) = %v, expected %v", tc.datamap, got, tc.expected)
			}
		})
	}
}