Skip to content

Commit

Permalink
fix unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: sbadiger <[email protected]>
  • Loading branch information
shreyas-badiger committed Aug 31, 2023
1 parent bd43f19 commit 0c4d664
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions api/v1alpha1/instancegroup_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type EksUnitTest struct {
}

func (u *EksUnitTest) Run(t *testing.T) string {
err := u.InstanceGroup.Validate(&ValidationOverrides{})
err := u.InstanceGroup.Validate(u.Overrides)
if err == nil {
return aws.StringValue(nil)
} else {
Expand Down Expand Up @@ -480,7 +480,7 @@ func TestScalingConfigOverride(t *testing.T) {
{
name: "override default to launchconfig instead of launchtemplate",
args: args{
instancegroup: MockInstanceGroup("eks-fargate", "managed", nil, nil, basicFargateSpec()),
instancegroup: MockInstanceGroup("eks", "managed", MockEKSSpec(), nil, basicFargateSpec()),
overrides: &ValidationOverrides{
scalingConfigurationOverride: &launchconfiguration,
},
Expand All @@ -490,15 +490,15 @@ func TestScalingConfigOverride(t *testing.T) {
{
name: "no default overrides",
args: args{
instancegroup: MockInstanceGroup("eks-fargate", "managed", nil, nil, basicFargateSpec()),
overrides: &ValidationOverrides{},
instancegroup: MockInstanceGroup("eks", "managed", MockEKSSpec(), nil, basicFargateSpec()),
overrides: &ValidationOverrides{},
},
want: LaunchTemplate,
},
{
name: "override default to launchtemplate",
args: args{
instancegroup: MockInstanceGroup("eks-fargate", "managed", nil, nil, basicFargateSpec()),
instancegroup: MockInstanceGroup("eks", "managed", MockEKSSpec(), nil, basicFargateSpec()),
overrides: &ValidationOverrides{
scalingConfigurationOverride: &launchtemplate,
},
Expand Down Expand Up @@ -585,3 +585,17 @@ func MockInstanceGroup(provisioner, strategy string, eksSpec *EKSSpec, eksManage
}

}

func MockEKSSpec() *EKSSpec {
return &EKSSpec{
Type: "invalid-scaling-config",
EKSConfiguration: &EKSConfiguration{
EksClusterName: "sample-cluster",
Subnets: []string{"subnet-1111111", "subnet-222222"},
NodeSecurityGroups: []string{"sg-sample-1", "sg-sample-2"},
Image: "sample-ami",
InstanceType: "sample-instance",
KeyPairName: "sample-key-pair",
},
}
}

0 comments on commit 0c4d664

Please sign in to comment.