-
Notifications
You must be signed in to change notification settings - Fork 52
/
registry_test.go
47 lines (40 loc) · 1.28 KB
/
registry_test.go
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
package registry_test
import (
"testing"
"github.com/commitdev/zero/internal/registry"
"github.com/stretchr/testify/assert"
)
func TestAvailableLabels(t *testing.T) {
reg := testRegistry()
t.Run("should be same order as declared", func(t *testing.T) {
labels := registry.AvailableLabels(reg)
assert.Equal(t, labels, []string{
"EKS + Go + React",
"foo",
"bar",
"lorem",
"ipsum",
"Custom",
})
})
}
func TestGetModulesByName(t *testing.T) {
reg := testRegistry()
t.Run("should return modules of specified stack", func(t *testing.T) {
assert.Equal(t, registry.GetModulesByName(reg, "EKS + Go + React"),
[]string{"module-source 1", "module-source 2"})
assert.Equal(t, registry.GetModulesByName(reg, "lorem"), []string{"module-source 5"})
assert.Equal(t, registry.GetModulesByName(reg, "ipsum"), []string{"module-source 6"})
assert.Equal(t, registry.GetModulesByName(reg, "Custom"), []string{"module-source 7"})
})
}
func testRegistry() registry.Registry {
return registry.Registry{
{"EKS + Go + React", []string{"module-source 1", "module-source 2"}},
{"foo", []string{"module-source 3"}},
{"bar", []string{"module-source 4"}},
{"lorem", []string{"module-source 5"}},
{"ipsum", []string{"module-source 6"}},
{"Custom", []string{"module-source 7"}},
}
}