Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
agouin committed Sep 18, 2023
1 parent e505b73 commit 8f07221
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
6 changes: 3 additions & 3 deletions internal/fullnode/build_pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ func BuildPods(crd *cosmosv1.CosmosFullNode, cksums ConfigChecksums) ([]diff.Res
if disable := overrides[pod.Name].DisableStrategy; disable != nil {
continue
}
if image := overrides[pod.Name].Image; image != "" {
pod.Spec.Containers[0].Image = image
}
if _, shouldSnapshot := candidates[pod.Name]; shouldSnapshot {
continue
}
if image := overrides[pod.Name].Image; image != "" {
pod.Spec.Containers[0].Image = image
}
pod.Annotations[configChecksumAnnotation] = cksums[client.ObjectKeyFromObject(pod)]
pods = append(pods, diff.Adapt(pod, i))
}
Expand Down
11 changes: 11 additions & 0 deletions internal/fullnode/build_pods_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,13 @@ func TestBuildPods(t *testing.T) {
},
Spec: cosmosv1.FullNodeSpec{
Replicas: 6,
PodTemplate: cosmosv1.PodSpec{
Image: "agoric:latest",
},
InstanceOverrides: map[string]cosmosv1.InstanceOverridesSpec{
"agoric-2": {DisableStrategy: ptr(cosmosv1.DisablePod)},
"agoric-4": {DisableStrategy: ptr(cosmosv1.DisableAll)},
"agoric-5": {Image: "some_image:custom"},
},
},
}
Expand All @@ -82,6 +86,13 @@ func TestBuildPods(t *testing.T) {
})
got := lo.Map(pods, func(pod diff.Resource[*corev1.Pod], _ int) string { return pod.Object().Name })
require.Equal(t, want, got)
for _, pod := range pods {
if pod.Object().Name == "agoric-5" {
require.Equal(t, "some_image:custom", pod.Object().Spec.Containers[0].Image)
} else {
require.Equal(t, "agoric:latest", pods[0].Object().Spec.Containers[0].Image)
}
}
})

t.Run("scheduled volume snapshot pod candidate", func(t *testing.T) {
Expand Down

0 comments on commit 8f07221

Please sign in to comment.