File tree Expand file tree Collapse file tree 3 files changed +57
-0
lines changed Expand file tree Collapse file tree 3 files changed +57
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ require (
9
9
github.com/go-logr/logr v0.3.0
10
10
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
11
11
github.com/prometheus/client_golang v1.7.1
12
+ github.com/stretchr/testify v1.5.1
12
13
golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0
13
14
golang.org/x/tools v0.0.0-20200714190737-9048b464a08d
14
15
k8s.io/api v0.20.1
Original file line number Diff line number Diff line change @@ -475,9 +475,11 @@ github.com/mailru/easyjson v0.7.0 h1:aizVhC/NAAcKWb+5QsU1iNOZb4Yws5UO2I+aIprQITM
475
475
github.com/mailru/easyjson v0.7.0 /go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs =
476
476
github.com/matoous/godox v0.0.0-20190911065817-5d6d842e92eb /go.mod h1:1BELzlh859Sh1c6+90blK8lbYy0kwQf1bYlBhBysy1s =
477
477
github.com/mattn/go-colorable v0.0.9 /go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU =
478
+ github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA =
478
479
github.com/mattn/go-colorable v0.1.4 /go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE =
479
480
github.com/mattn/go-isatty v0.0.3 /go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4 =
480
481
github.com/mattn/go-isatty v0.0.4 /go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4 =
482
+ github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE =
481
483
github.com/mattn/go-isatty v0.0.8 /go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s =
482
484
github.com/mattn/go-runewidth v0.0.2 /go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU =
483
485
github.com/mattn/goveralls v0.0.2 /go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw =
Original file line number Diff line number Diff line change
1
+ package declarative
2
+
3
+ import (
4
+ "testing"
5
+
6
+ "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
7
+ "k8s.io/apimachinery/pkg/runtime/schema"
8
+ "sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/declarative/pkg/manifest"
9
+
10
+ "github.com/stretchr/testify/assert"
11
+ )
12
+
13
+ func Test_uniqueGroupVersionKind (t * testing.T ) {
14
+ sa := & unstructured.Unstructured {
15
+ Object : map [string ]interface {}{
16
+ "apiVersion" : "v1" ,
17
+ "kind" : "ServiceAccount" ,
18
+ "metadata" : map [string ]interface {}{
19
+ "name" : "foo-operator" ,
20
+ "namespace" : "kube-system" ,
21
+ },
22
+ },
23
+ }
24
+ saObj , _ := manifest .NewObject (sa )
25
+
26
+ tests := []struct {
27
+ name string
28
+ inputObjects * manifest.Objects
29
+ expectSchema []schema.GroupVersionKind
30
+ }{
31
+ {
32
+ name : "single object" ,
33
+ inputObjects : & manifest.Objects {
34
+ Items : []* manifest.Object {
35
+ saObj ,
36
+ },
37
+ },
38
+ expectSchema : []schema.GroupVersionKind {
39
+ {
40
+ Group : "" ,
41
+ Version : "v1" ,
42
+ Kind : "ServiceAccount" ,
43
+ },
44
+ },
45
+ },
46
+ }
47
+
48
+ for _ , tt := range tests {
49
+ t .Run (tt .name , func (t * testing.T ) {
50
+ actualSchema := uniqueGroupVersionKind (tt .inputObjects )
51
+ assert .Equal (t , tt .expectSchema , actualSchema )
52
+ })
53
+ }
54
+ }
You can’t perform that action at this time.
0 commit comments