File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change 44package object
55
66import (
7+ "strings"
78 "testing"
89
910 "k8s.io/apimachinery/pkg/runtime/schema"
@@ -97,7 +98,22 @@ func TestCreateObjMetadata(t *testing.T) {
9798 if err != nil {
9899 t .Errorf ("Error creating ObjMetadata when it should have worked." )
99100 } else if test .expected != inv .String () {
100- t .Errorf ("Expected inventory (%s) != created inventory(%s)\n " , test .expected , inv .String ())
101+ t .Errorf ("Expected inventory\n (%s) != created inventory\n (%s)\n " , test .expected , inv .String ())
102+ }
103+
104+ // Parsing back the just created inventory string to ObjMetadata,
105+ // so that tests will catch any change to CreateObjMetadata that
106+ // would break ParseObjMetadata.
107+ expectedObjMetadata := & ObjMetadata {
108+ Namespace : strings .TrimSpace (test .namespace ),
109+ Name : strings .TrimSpace (test .name ),
110+ GroupKind : test .gk ,
111+ }
112+ actual , err := ParseObjMetadata (inv .String ())
113+ if err != nil {
114+ t .Errorf ("Error parsing back ObjMetadata, when it should have worked." )
115+ } else if ! expectedObjMetadata .Equals (actual ) {
116+ t .Errorf ("Expected inventory (%s) != parsed inventory (%s)\n " , expectedObjMetadata , actual )
101117 }
102118 }
103119 if test .isError && err == nil {
You can’t perform that action at this time.
0 commit comments