-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathbuild_context_test.go
More file actions
44 lines (36 loc) · 1022 Bytes
/
build_context_test.go
File metadata and controls
44 lines (36 loc) · 1022 Bytes
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
package operator
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestBuildContext(t *testing.T) {
t.Run("PrependNamespace", func(t *testing.T) {
bc := BuildContext{
Namespace: "$.test",
}
t.Run("Standard", func(t *testing.T) {
id := bc.PrependNamespace("testid")
require.Equal(t, "$.test.testid", id)
})
t.Run("AlreadyPrefixed", func(t *testing.T) {
id := bc.PrependNamespace("$.myns.testid")
require.Equal(t, "$.myns.testid", id)
})
})
t.Run("WithSubNamespace", func(t *testing.T) {
bc := BuildContext{
Namespace: "$.ns",
}
bc2 := bc.WithSubNamespace("subns")
require.Equal(t, "$.ns.subns", bc2.Namespace)
require.Equal(t, "$.ns", bc.Namespace)
})
t.Run("WithDefaultOutputIDs", func(t *testing.T) {
bc := BuildContext{
DefaultOutputIDs: []string{"orig"},
}
bc2 := bc.WithDefaultOutputIDs([]string{"id1", "id2"})
require.Equal(t, []string{"id1", "id2"}, bc2.DefaultOutputIDs)
require.Equal(t, []string{"orig"}, bc.DefaultOutputIDs)
})
}