Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
preflightsiren committed Oct 1, 2021
1 parent 931b500 commit a5a0b85
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
9 changes: 9 additions & 0 deletions controllers/provisioners/eks/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,15 @@ func TestCreateLatestAMI(t *testing.T) {
ig.GetEKSConfiguration().Image = "latest"
ssmMock.latestAMI = testLatestAmiID

ec2Mock.InstanceTypes = []*ec2.InstanceTypeInfo{
&ec2.InstanceTypeInfo{
InstanceType: aws.String("m5.large"),
ProcessorInfo: &ec2.ProcessorInfo{
SupportedArchitectures: []*string{aws.String("x86_64")},
},
},
}

err := ctx.CloudDiscovery()
g.Expect(err).NotTo(gomega.HaveOccurred())
// Must happen after ctx.CloudDiscover()
Expand Down
30 changes: 25 additions & 5 deletions controllers/provisioners/eks/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,30 @@ func TestUpdateWithLatestAmiID(t *testing.T) {
}
asgMock.AutoScalingGroups = []*autoscaling.Group{mockScalingGroup}

// skip role creation
ig.GetEKSConfiguration().SetInstanceProfileName("some-profile")
ig.GetEKSConfiguration().SetRoleName("some-role")
iamMock.Role = &iam.Role{
Arn: aws.String("some-arn"),
RoleName: aws.String("some-role"),
}

// Setup Latest AMI
ig.GetEKSConfiguration().Image = "latest"
ssmMock.latestAMI = testLatestAmiID

ec2Mock.InstanceTypes = []*ec2.InstanceTypeInfo{
&ec2.InstanceTypeInfo{
InstanceType: aws.String("m5.large"),
ProcessorInfo: &ec2.ProcessorInfo{
SupportedArchitectures: []*string{aws.String("x86_64")},
},
},
}

err := ctx.CloudDiscovery()
g.Expect(err).NotTo(gomega.HaveOccurred())

ctx.SetDiscoveredState(&DiscoveredState{
Publisher: kubeprovider.EventPublisher{
Client: k.Kubernetes,
Expand All @@ -752,11 +776,7 @@ func TestUpdateWithLatestAmiID(t *testing.T) {
},
})

// Setup Latest AMI
ig.GetEKSConfiguration().Image = "latest"
ssmMock.latestAMI = testLatestAmiID

err := ctx.Update()
err = ctx.Update()
g.Expect(err).NotTo(gomega.HaveOccurred())
g.Expect(ctx.GetInstanceGroup().Spec.EKSSpec.EKSConfiguration.Image).To(gomega.Equal(testLatestAmiID))
}

0 comments on commit a5a0b85

Please sign in to comment.