Skip to content

Commit 610691b

Browse files
committed
added unit test
1 parent a481de3 commit 610691b

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

exp/controllers/rosamachinepool_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ func nodePoolBuilder(rosaMachinePoolSpec expinfrav1.RosaMachinePoolSpec, machine
423423
func nodePoolToRosaMachinePoolSpec(nodePool *cmv1.NodePool) expinfrav1.RosaMachinePoolSpec {
424424
spec := expinfrav1.RosaMachinePoolSpec{
425425
NodePoolName: nodePool.ID(),
426-
Version: nodePool.Version().RawID(),
426+
Version: rosa.RawVersionID(nodePool.Version()),
427427
AvailabilityZone: nodePool.AvailabilityZone(),
428428
Subnet: nodePool.Subnet(),
429429
Labels: nodePool.Labels(),
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package controllers
2+
3+
import (
4+
"testing"
5+
6+
. "github.com/onsi/gomega"
7+
"k8s.io/utils/ptr"
8+
9+
expinfrav1 "sigs.k8s.io/cluster-api-provider-aws/v2/exp/api/v1beta2"
10+
expclusterv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1"
11+
)
12+
13+
func TestNodePoolToRosaMachinePoolSpec(t *testing.T) {
14+
g := NewWithT(t)
15+
16+
rosaMachinePoolSpec := expinfrav1.RosaMachinePoolSpec{
17+
NodePoolName: "test-nodepool",
18+
Version: "4.14.5",
19+
Subnet: "subnet-id",
20+
AutoRepair: true,
21+
InstanceType: "m5.large",
22+
TuningConfigs: []string{"config1"},
23+
}
24+
25+
machinePoolSpec := expclusterv1.MachinePoolSpec{
26+
Replicas: ptr.To[int32](2),
27+
}
28+
29+
nodePoolBuilder := nodePoolBuilder(rosaMachinePoolSpec, machinePoolSpec)
30+
31+
nodePoolSpec, err := nodePoolBuilder.Build()
32+
g.Expect(err).ToNot(HaveOccurred())
33+
34+
expectedSpec := nodePoolToRosaMachinePoolSpec(nodePoolSpec)
35+
36+
g.Expect(expectedSpec).To(Equal(rosaMachinePoolSpec))
37+
}

0 commit comments

Comments
 (0)