Skip to content

Commit 577bcda

Browse files
committed
tests(awsmachine controller): fix test that matched bug behavior
1 parent f528a75 commit 577bcda

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

controllers/awsmachine_controller_unit_test.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ func TestAWSMachineReconciler(t *testing.T) {
481481
}
482482
})
483483

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

495495
ec2Svc.EXPECT().GetAdditionalSecurityGroupsIDs(gomock.Any()).Return(nil, nil)
496+
497+
// expect one call first to tag the instance and two calls for tagging each of two volumes
498+
// the volumes get the tags from the AWSCluster _and_ the AWSMachine
499+
496500
ec2Svc.EXPECT().UpdateResourceTags(
497-
gomock.Any(),
501+
PointsTo("myMachine"),
498502
map[string]string{
499-
"kind": "alicorn",
503+
"colour": "lavender",
504+
"kind": "alicorn",
500505
},
501506
map[string]string{},
502-
).Return(nil).Times(2)
507+
).Return(nil)
503508

504509
ec2Svc.EXPECT().UpdateResourceTags(
505-
PointsTo("myMachine"),
510+
gomock.Any(),
511+
//create
506512
map[string]string{
507513
"colour": "lavender",
508514
"kind": "alicorn",
509515
},
516+
//remove
510517
map[string]string{},
511-
).Return(nil)
518+
).Return(nil).Times(2)
512519

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

0 commit comments

Comments
 (0)