Skip to content

Commit

Permalink
tests(awsmachine controller): fix test that matched bug behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
philjb committed Sep 22, 2023
1 parent f528a75 commit 577bcda
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions controllers/awsmachine_controller_unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ func TestAWSMachineReconciler(t *testing.T) {
}
})

t.Run("should tag instances from machine and cluster tags", func(t *testing.T) {
t.Run("should tag instances and volumes with machine and cluster tags", func(t *testing.T) {
g := NewWithT(t)
awsMachine := getAWSMachine()
setup(t, g, awsMachine)
Expand All @@ -493,22 +493,29 @@ func TestAWSMachineReconciler(t *testing.T) {
cs.AWSCluster.Spec.AdditionalTags = infrav1.Tags{"colour": "lavender"}

ec2Svc.EXPECT().GetAdditionalSecurityGroupsIDs(gomock.Any()).Return(nil, nil)

// expect one call first to tag the instance and two calls for tagging each of two volumes
// the volumes get the tags from the AWSCluster _and_ the AWSMachine

ec2Svc.EXPECT().UpdateResourceTags(
gomock.Any(),
PointsTo("myMachine"),
map[string]string{
"kind": "alicorn",
"colour": "lavender",
"kind": "alicorn",
},
map[string]string{},
).Return(nil).Times(2)
).Return(nil)

ec2Svc.EXPECT().UpdateResourceTags(
PointsTo("myMachine"),
gomock.Any(),
//create
map[string]string{
"colour": "lavender",
"kind": "alicorn",
},
//remove
map[string]string{},
).Return(nil)
).Return(nil).Times(2)

_, err := reconciler.reconcileNormal(context.Background(), ms, cs, cs, cs, cs)
g.Expect(err).To(BeNil())
Expand Down

0 comments on commit 577bcda

Please sign in to comment.