@@ -17,7 +17,7 @@ func TestReorderNodeGroups(t *testing.T) {
17
17
apiNodeGroups []* client.AzureEnvSpecFragment_NodeGroups
18
18
expectedOrder []string
19
19
expectedLength int
20
- validateData bool // Whether to validate specific field values
20
+ validateData bool
21
21
}{
22
22
{
23
23
name : "Preserve model order and add new API node groups" ,
@@ -28,7 +28,7 @@ func TestReorderNodeGroups(t *testing.T) {
28
28
apiNodeGroups : []* client.AzureEnvSpecFragment_NodeGroups {
29
29
{NodeType : "user" , Name : "user-group" , CapacityPerZone : 2 },
30
30
{NodeType : "system" , Name : "system-group" , CapacityPerZone : 1 },
31
- {NodeType : "monitoring" , Name : "monitoring-group" , CapacityPerZone : 1 }, // New node group not in model
31
+ {NodeType : "monitoring" , Name : "monitoring-group" , CapacityPerZone : 1 },
32
32
},
33
33
expectedOrder : []string {"system" , "user" , "monitoring" },
34
34
expectedLength : 3 ,
@@ -51,7 +51,7 @@ func TestReorderNodeGroups(t *testing.T) {
51
51
model : []common.NodeGroupsModel {
52
52
{NodeType : types .StringValue ("system" )},
53
53
{NodeType : types .StringValue ("user" )},
54
- {NodeType : types .StringValue ("missing" )}, // Not in API
54
+ {NodeType : types .StringValue ("missing" )},
55
55
},
56
56
apiNodeGroups : []* client.AzureEnvSpecFragment_NodeGroups {
57
57
{NodeType : "user" , Name : "user-group" , CapacityPerZone : 2 },
@@ -125,9 +125,8 @@ func TestReorderNodeGroups(t *testing.T) {
125
125
}
126
126
}
127
127
128
- // Additional data validation for the "No data loss validation" test case
129
128
if tt .validateData {
130
- // Verify system is first (from model order)
129
+
131
130
if result [0 ].NodeType != "system" {
132
131
t .Errorf ("Expected first node type to be 'system', got '%s'" , result [0 ].NodeType )
133
132
}
@@ -138,7 +137,6 @@ func TestReorderNodeGroups(t *testing.T) {
138
137
t .Errorf ("Expected system CapacityPerZone to be 10, got %d" , result [0 ].CapacityPerZone )
139
138
}
140
139
141
- // Verify other node groups are preserved with their data
142
140
nodeTypeToGroup := make (map [string ]* client.AzureEnvSpecFragment_NodeGroups )
143
141
for _ , group := range result {
144
142
nodeTypeToGroup [group .NodeType ] = group
@@ -360,7 +358,7 @@ func TestLoadBalancersToSDK(t *testing.T) {
360
358
}
361
359
362
360
if tt .expected != nil && result != nil {
363
- // Compare public load balancer
361
+
364
362
if (tt .expected .Public == nil ) != (result .Public == nil ) {
365
363
t .Errorf ("Public load balancer presence mismatch" )
366
364
}
@@ -373,7 +371,6 @@ func TestLoadBalancersToSDK(t *testing.T) {
373
371
}
374
372
}
375
373
376
- // Compare internal load balancer
377
374
if (tt .expected .Internal == nil ) != (result .Internal == nil ) {
378
375
t .Errorf ("Internal load balancer presence mismatch" )
379
376
}
@@ -457,7 +454,6 @@ func TestLoadBalancersToModel(t *testing.T) {
457
454
return
458
455
}
459
456
460
- // Test public load balancer
461
457
if result .Public == nil {
462
458
t .Error ("Expected non-nil Public load balancer" )
463
459
return
@@ -469,7 +465,6 @@ func TestLoadBalancersToModel(t *testing.T) {
469
465
t .Errorf ("Public SourceIPRanges count: expected %d, got %d" , tt .expected .publicSourceIPCount , len (result .Public .SourceIPRanges ))
470
466
}
471
467
472
- // Test internal load balancer
473
468
if result .Internal == nil {
474
469
t .Error ("Expected non-nil Internal load balancer" )
475
470
return
@@ -700,7 +695,6 @@ func TestNodeGroupsToModel(t *testing.T) {
700
695
t .Errorf ("Node group %d CapacityPerZone: expected %d, got %d" , i , expected .capacityPerZone , result [i ].CapacityPerZone .ValueInt64 ())
701
696
}
702
697
703
- // Check zones count by converting List to slice
704
698
var zones []string
705
699
result [i ].Zones .ElementsAs (context .TODO (), & zones , false )
706
700
if len (zones ) != expected .zonesCount {
@@ -763,7 +757,7 @@ func TestAzureEnvResourceModel_toSDK(t *testing.T) {
763
757
},
764
758
},
765
759
validate : func (t * testing.T , create client.CreateAzureEnvInput , update client.UpdateAzureEnvInput ) {
766
- // Validate create input
760
+
767
761
if create .Name != "test-azure-env" {
768
762
t .Errorf ("Create name: expected 'test-azure-env', got '%s'" , create .Name )
769
763
}
@@ -798,7 +792,6 @@ func TestAzureEnvResourceModel_toSDK(t *testing.T) {
798
792
t .Errorf ("Create private link allowed subscriptions: expected 2, got %d" , len (create .Spec .PrivateLinkService .AllowedSubscriptions ))
799
793
}
800
794
801
- // Validate update input
802
795
if update .Name != "test-azure-env" {
803
796
t .Errorf ("Update name: expected 'test-azure-env', got '%s'" , update .Name )
804
797
}
@@ -972,38 +965,33 @@ func TestAzureEnvResourceModel_toModel(t *testing.T) {
972
965
t .Errorf ("LoadBalancingStrategy: expected 'ROUND_ROBIN', got '%s'" , model .LoadBalancingStrategy .ValueString ())
973
966
}
974
967
975
- // Check zones
976
968
var zones []string
977
969
model .Zones .ElementsAs (context .TODO (), & zones , false )
978
970
if len (zones ) != 3 {
979
971
t .Errorf ("Zones count: expected 3, got %d" , len (zones ))
980
972
}
981
973
982
- // Check node groups
983
974
if len (model .NodeGroups ) != 2 {
984
975
t .Errorf ("NodeGroups count: expected 2, got %d" , len (model .NodeGroups ))
985
976
}
986
977
if model .NodeGroups [0 ].Name .ValueString () != "system-group" {
987
978
t .Errorf ("First node group name: expected 'system-group', got '%s'" , model .NodeGroups [0 ].Name .ValueString ())
988
979
}
989
980
990
- // Check maintenance windows
991
981
if len (model .MaintenanceWindows ) != 1 {
992
982
t .Errorf ("MaintenanceWindows count: expected 1, got %d" , len (model .MaintenanceWindows ))
993
983
}
994
984
if model .MaintenanceWindows [0 ].Name .ValueString () != "weekly-maintenance" {
995
985
t .Errorf ("Maintenance window name: expected 'weekly-maintenance', got '%s'" , model .MaintenanceWindows [0 ].Name .ValueString ())
996
986
}
997
987
998
- // Check tags
999
988
if len (model .Tags ) != 2 {
1000
989
t .Errorf ("Tags count: expected 2, got %d" , len (model .Tags ))
1001
990
}
1002
991
if model .Tags [0 ].Key .ValueString () != "Environment" {
1003
992
t .Errorf ("First tag key: expected 'Environment', got '%s'" , model .Tags [0 ].Key .ValueString ())
1004
993
}
1005
994
1006
- // Check load balancers
1007
995
if model .LoadBalancers == nil {
1008
996
t .Fatal ("LoadBalancers should not be nil" )
1009
997
}
@@ -1014,7 +1002,6 @@ func TestAzureEnvResourceModel_toModel(t *testing.T) {
1014
1002
t .Errorf ("Public load balancer enabled: expected true, got %v" , model .LoadBalancers .Public .Enabled .ValueBool ())
1015
1003
}
1016
1004
1017
- // Check private link service
1018
1005
if model .PrivateLinkService == nil {
1019
1006
t .Fatal ("PrivateLinkService should not be nil" )
1020
1007
}
@@ -1069,7 +1056,6 @@ func TestAzureEnvResourceModel_toModel(t *testing.T) {
1069
1056
t .Errorf ("SubscriptionID: expected 'subscription-min', got '%s'" , model .SubscriptionID .ValueString ())
1070
1057
}
1071
1058
1072
- // Check empty collections
1073
1059
if len (model .NodeGroups ) != 0 {
1074
1060
t .Errorf ("NodeGroups: expected empty slice, got %d items" , len (model .NodeGroups ))
1075
1061
}
@@ -1125,7 +1111,6 @@ func TestAzureEnvResourceModel_toModel(t *testing.T) {
1125
1111
t .Errorf ("LoadBalancingStrategy: expected 'ROUND_ROBIN', got '%s'" , model .LoadBalancingStrategy .ValueString ())
1126
1112
}
1127
1113
1128
- // Check zones
1129
1114
var zones []string
1130
1115
model .Zones .ElementsAs (context .TODO (), & zones , false )
1131
1116
if len (zones ) != 2 {
0 commit comments