Skip to content

Commit

Permalink
added test to catch creationTimestamp bug regressions
Browse files Browse the repository at this point in the history
  • Loading branch information
killianmuldoon committed Nov 3, 2021
1 parent 47f39c2 commit 5031e32
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions internal/matchers/matchers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,32 @@ func TestEqualObjectMatcher(t *testing.T) {
},
want: false,
},
{
name: "Creation timestamp exists on modified but not on original",
original: &unstructured.Unstructured{
Object: map[string]interface{}{
"spec": map[string]interface{}{
"A": "A",
},
"metadata": map[string]interface{}{
"selfLink": "foo",
"creationTimestamp": "2020-07-11T00:00:00Z",
},
},
},
modified: &unstructured.Unstructured{
Object: map[string]interface{}{
"spec": map[string]interface{}{
"A": "A",
},
"metadata": map[string]interface{}{
"selfLink": "foo",
"creationTimestamp": "2021-11-03T11:05:17Z",
},
},
},
want: false,
},

// Cases to test diff when fields exist only in modified object.
{
Expand Down Expand Up @@ -212,6 +238,28 @@ func TestEqualObjectMatcher(t *testing.T) {
},
want: false,
},
{
name: "Creation timestamp exists on modified but not on original",
original: &unstructured.Unstructured{
Object: map[string]interface{}{
"spec": map[string]interface{}{
"A": "A",
},
},
},
modified: &unstructured.Unstructured{
Object: map[string]interface{}{
"spec": map[string]interface{}{
"A": "A",
},
"metadata": map[string]interface{}{
"selfLink": "foo",
"creationTimestamp": "2021-11-03T11:05:17Z",
},
},
},
want: false,
},

// Test when fields are exists only in the original object.
{
Expand Down Expand Up @@ -246,6 +294,29 @@ func TestEqualObjectMatcher(t *testing.T) {
},
want: false,
},
{
name: "Creation timestamp exists on original but not on modified",
original: &unstructured.Unstructured{
Object: map[string]interface{}{
"spec": map[string]interface{}{
"A": "A",
},
"metadata": map[string]interface{}{
"selfLink": "foo",
"creationTimestamp": "2021-11-03T11:05:17Z",
},
},
},
modified: &unstructured.Unstructured{
Object: map[string]interface{}{
"spec": map[string]interface{}{
"A": "A",
},
},
},

want: false,
},

// Test metadata fields computed by the system or in status are compared.
{
Expand Down

0 comments on commit 5031e32

Please sign in to comment.