Skip to content

Commit 5031e32

Browse files
added test to catch creationTimestamp bug regressions
1 parent 47f39c2 commit 5031e32

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

internal/matchers/matchers_test.go

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,32 @@ func TestEqualObjectMatcher(t *testing.T) {
178178
},
179179
want: false,
180180
},
181+
{
182+
name: "Creation timestamp exists on modified but not on original",
183+
original: &unstructured.Unstructured{
184+
Object: map[string]interface{}{
185+
"spec": map[string]interface{}{
186+
"A": "A",
187+
},
188+
"metadata": map[string]interface{}{
189+
"selfLink": "foo",
190+
"creationTimestamp": "2020-07-11T00:00:00Z",
191+
},
192+
},
193+
},
194+
modified: &unstructured.Unstructured{
195+
Object: map[string]interface{}{
196+
"spec": map[string]interface{}{
197+
"A": "A",
198+
},
199+
"metadata": map[string]interface{}{
200+
"selfLink": "foo",
201+
"creationTimestamp": "2021-11-03T11:05:17Z",
202+
},
203+
},
204+
},
205+
want: false,
206+
},
181207

182208
// Cases to test diff when fields exist only in modified object.
183209
{
@@ -212,6 +238,28 @@ func TestEqualObjectMatcher(t *testing.T) {
212238
},
213239
want: false,
214240
},
241+
{
242+
name: "Creation timestamp exists on modified but not on original",
243+
original: &unstructured.Unstructured{
244+
Object: map[string]interface{}{
245+
"spec": map[string]interface{}{
246+
"A": "A",
247+
},
248+
},
249+
},
250+
modified: &unstructured.Unstructured{
251+
Object: map[string]interface{}{
252+
"spec": map[string]interface{}{
253+
"A": "A",
254+
},
255+
"metadata": map[string]interface{}{
256+
"selfLink": "foo",
257+
"creationTimestamp": "2021-11-03T11:05:17Z",
258+
},
259+
},
260+
},
261+
want: false,
262+
},
215263

216264
// Test when fields are exists only in the original object.
217265
{
@@ -246,6 +294,29 @@ func TestEqualObjectMatcher(t *testing.T) {
246294
},
247295
want: false,
248296
},
297+
{
298+
name: "Creation timestamp exists on original but not on modified",
299+
original: &unstructured.Unstructured{
300+
Object: map[string]interface{}{
301+
"spec": map[string]interface{}{
302+
"A": "A",
303+
},
304+
"metadata": map[string]interface{}{
305+
"selfLink": "foo",
306+
"creationTimestamp": "2021-11-03T11:05:17Z",
307+
},
308+
},
309+
},
310+
modified: &unstructured.Unstructured{
311+
Object: map[string]interface{}{
312+
"spec": map[string]interface{}{
313+
"A": "A",
314+
},
315+
},
316+
},
317+
318+
want: false,
319+
},
249320

250321
// Test metadata fields computed by the system or in status are compared.
251322
{

0 commit comments

Comments
 (0)