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 4
4
package object
5
5
6
6
import (
7
+ "strings"
7
8
"testing"
8
9
9
10
"k8s.io/apimachinery/pkg/runtime/schema"
@@ -97,7 +98,22 @@ func TestCreateObjMetadata(t *testing.T) {
97
98
if err != nil {
98
99
t .Errorf ("Error creating ObjMetadata when it should have worked." )
99
100
} 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 )
101
117
}
102
118
}
103
119
if test .isError && err == nil {
You can’t perform that action at this time.
0 commit comments