Skip to content

Commit

Permalink
address test comments
Browse files Browse the repository at this point in the history
Signed-off-by: Jordan Rodgers <jrodgers@figma.com>
  • Loading branch information
com6056 committed Jan 31, 2025
1 parent eff2505 commit 76395a3
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions utils/replicaset/canary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1339,23 +1339,20 @@ func TestSyncEphemeralPodMetadata(t *testing.T) {
"ddd": "444",
},
}
{
// verify modified is false if there are no changes
t.Run("verify modified is false if there are no changes", func(t *testing.T) {
newMetadata, modified := SyncEphemeralPodMetadata(&meta, &existing, &existing)
assert.False(t, modified)
assert.Equal(t, meta, *newMetadata)
}
{
// verify modified is false if there are no actual deletions
desired := existing.DeepCopy()
existing.Labels["foo"] = "bar"
newMetadata, modified := SyncEphemeralPodMetadata(&meta, &existing, desired)
})
t.Run("verify modified is false if there are no actual deletions", func(t *testing.T) {
existingWithExtraLabel := existing.DeepCopy()
existingWithExtraLabel.Labels["foo"] = "bar"
newMetadata, modified := SyncEphemeralPodMetadata(&meta, existingWithExtraLabel, &existing)
assert.False(t, modified)
assert.Equal(t, meta, *newMetadata)
delete(existing.Labels, "foo")
}
{
// verify we don't touch metadata that we did not inject ourselves
})
t.Run("verify we don't touch metadata that we did not inject ourselves", func(t *testing.T) {
desired := v1alpha1.PodTemplateMetadata{
Labels: map[string]string{
"aaa": "222",
Expand All @@ -1365,7 +1362,6 @@ func TestSyncEphemeralPodMetadata(t *testing.T) {
},
}
newMetadata, modified := SyncEphemeralPodMetadata(&meta, &existing, &desired)
assert.True(t, modified)
expected := metav1.ObjectMeta{
Labels: map[string]string{
"aaa": "222",
Expand All @@ -1376,8 +1372,9 @@ func TestSyncEphemeralPodMetadata(t *testing.T) {
"do-not": "touch",
},
}
assert.True(t, modified)
assert.Equal(t, expected, *newMetadata)
}
})
}

func TestGetReplicasForScaleDown(t *testing.T) {
Expand Down

0 comments on commit 76395a3

Please sign in to comment.