Skip to content

Commit

Permalink
Fix some unit test issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mboersma committed Aug 21, 2023
1 parent 1f964db commit 6b286b9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions azure/services/managedclusters/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ func (s *ManagedClusterSpec) Parameters(ctx context.Context, existing interface{
managedCluster.Properties.AgentPoolProfiles = existingMC.Properties.AgentPoolProfiles

// if the AuthorizedIPRanges is nil in the user-updated spec, but not nil in the existing spec, then
// we need to set the AuthorizedIPRanges to empty array (&[]string{}) once so that the Azure API will
// we need to set the AuthorizedIPRanges to empty array ([]*string{}) once so that the Azure API will
// update the existing authorized IP ranges to nil.
if !isAuthIPRangesNilOrEmpty(existingMC) && isAuthIPRangesNilOrEmpty(managedCluster) {
log.V(4).Info("managed cluster spec has nil AuthorizedIPRanges, updating existing authorized IP ranges to an empty list")
Expand Down Expand Up @@ -718,5 +718,5 @@ func getIdentity(identity *infrav1.Identity) (managedClusterIdentity *armcontain
func isAuthIPRangesNilOrEmpty(managedCluster armcontainerservice.ManagedCluster) bool {
return managedCluster.Properties.APIServerAccessProfile == nil ||
managedCluster.Properties.APIServerAccessProfile.AuthorizedIPRanges == nil ||
reflect.DeepEqual(managedCluster.Properties.APIServerAccessProfile.AuthorizedIPRanges, &[]string{})
reflect.DeepEqual(managedCluster.Properties.APIServerAccessProfile.AuthorizedIPRanges, []*string{})
}
28 changes: 14 additions & 14 deletions azure/services/managedclusters/spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func TestParameters(t *testing.T) {
"test-tag": "test-value",
},
Version: "v1.22.0",
LoadBalancerSKU: "Standard",
LoadBalancerSKU: "standard",
SSHPublicKey: base64.StdEncoding.EncodeToString([]byte("test-ssh-key")),
GetAllAgentPools: func() ([]azure.ResourceSpecGetter, error) {
return []azure.ResourceSpecGetter{
Expand Down Expand Up @@ -116,7 +116,7 @@ func TestParameters(t *testing.T) {
"test-tag": "test-value",
},
Version: "v1.22.0",
LoadBalancerSKU: "Standard",
LoadBalancerSKU: "standard",
},
expect: func(g *WithT, result interface{}) {
g.Expect(result).To(BeNil())
Expand All @@ -133,7 +133,7 @@ func TestParameters(t *testing.T) {
"test-tag": "test-value",
},
Version: "v1.22.99",
LoadBalancerSKU: "Standard",
LoadBalancerSKU: "standard",
Identity: &infrav1.Identity{
Type: infrav1.ManagedControlPlaneIdentityTypeUserAssigned,
UserAssignedIdentityResourceID: "/resource/ID",
Expand All @@ -157,7 +157,7 @@ func TestParameters(t *testing.T) {
Location: "test-location",
Tags: nil,
Version: "v1.22.0",
LoadBalancerSKU: "Standard",
LoadBalancerSKU: "standard",
},
expect: func(g *WithT, result interface{}) {
// Additional tags are handled by azure/services/tags, so a diff
Expand All @@ -174,7 +174,7 @@ func TestParameters(t *testing.T) {
Location: "test-location",
Tags: nil,
Version: "v1.22.0",
LoadBalancerSKU: "Standard",
LoadBalancerSKU: "standard",
SSHPublicKey: base64.StdEncoding.EncodeToString([]byte("test-ssh-key")),
GetAllAgentPools: func() ([]azure.ResourceSpecGetter, error) {
return []azure.ResourceSpecGetter{
Expand Down Expand Up @@ -205,7 +205,7 @@ func TestParameters(t *testing.T) {
Location: "test-location",
Tags: nil,
Version: "v1.22.0",
LoadBalancerSKU: "Standard",
LoadBalancerSKU: "standard",
HTTPProxyConfig: &HTTPProxyConfig{
HTTPProxy: ptr.To("http://proxy.com"),
HTTPSProxy: ptr.To("https://proxy.com"),
Expand All @@ -229,7 +229,7 @@ func TestParameters(t *testing.T) {
Location: "test-location",
Tags: nil,
Version: "v1.22.0",
LoadBalancerSKU: "Standard",
LoadBalancerSKU: "standard",
HTTPProxyConfig: &HTTPProxyConfig{
NoProxy: []string{"noproxy1", "noproxy2"},
},
Expand All @@ -240,7 +240,7 @@ func TestParameters(t *testing.T) {
expect: func(g *WithT, result interface{}) {
g.Expect(result).To(BeAssignableToTypeOf(armcontainerservice.ManagedCluster{}))
g.Expect(result.(armcontainerservice.ManagedCluster).Properties.HTTPProxyConfig).To(Not(BeNil()))
g.Expect((result.(armcontainerservice.ManagedCluster).Properties.HTTPProxyConfig.NoProxy)).To(Equal([]string{"noproxy1", "noproxy2"}))
g.Expect((result.(armcontainerservice.ManagedCluster).Properties.HTTPProxyConfig.NoProxy)).To(Equal([]*string{ptr.To("noproxy1"), ptr.To("noproxy2")}))
},
},
{
Expand All @@ -252,7 +252,7 @@ func TestParameters(t *testing.T) {
Location: "test-location",
Tags: nil,
Version: "v1.22.0",
LoadBalancerSKU: "Standard",
LoadBalancerSKU: "standard",
SSHPublicKey: "",
GetAllAgentPools: func() ([]azure.ResourceSpecGetter, error) {
return []azure.ResourceSpecGetter{
Expand Down Expand Up @@ -284,7 +284,7 @@ func TestParameters(t *testing.T) {
"test-tag": "test-value",
},
Version: "v1.22.0",
LoadBalancerSKU: "Standard",
LoadBalancerSKU: "standard",
APIServerAccessProfile: &APIServerAccessProfile{
AuthorizedIPRanges: func() []string {
var arr []string
Expand All @@ -307,7 +307,7 @@ func TestParameters(t *testing.T) {
"test-tag": "test-value",
},
Version: "v1.22.0",
LoadBalancerSKU: "Standard",
LoadBalancerSKU: "standard",
},
expect: func(g *WithT, result interface{}) {
g.Expect(result).To(BeAssignableToTypeOf(armcontainerservice.ManagedCluster{}))
Expand All @@ -326,15 +326,15 @@ func TestParameters(t *testing.T) {
"test-tag": "test-value",
},
Version: "v1.22.0",
LoadBalancerSKU: "Standard",
LoadBalancerSKU: "standard",
APIServerAccessProfile: &APIServerAccessProfile{
AuthorizedIPRanges: []string{"192.168.0.1/32, 192.168.0.2/32, 192.168.0.3/32"},
},
},
expect: func(g *WithT, result interface{}) {
g.Expect(result).To(BeAssignableToTypeOf(armcontainerservice.ManagedCluster{}))
g.Expect(result.(armcontainerservice.ManagedCluster).Properties.APIServerAccessProfile).To(Not(BeNil()))
g.Expect(result.(armcontainerservice.ManagedCluster).Properties.APIServerAccessProfile.AuthorizedIPRanges).To(Equal([]*string{ptr.To("192.168.0.1/32"), ptr.To("192.168.0.2/32"), ptr.To("192.168.0.3/32")}))
g.Expect(result.(armcontainerservice.ManagedCluster).Properties.APIServerAccessProfile.AuthorizedIPRanges).To(Equal([]*string{ptr.To("192.168.0.1/32, 192.168.0.2/32, 192.168.0.3/32")}))
},
},
{
Expand All @@ -348,7 +348,7 @@ func TestParameters(t *testing.T) {
"test-tag": "test-value",
},
Version: "v1.22.0",
LoadBalancerSKU: "Standard",
LoadBalancerSKU: "standard",
APIServerAccessProfile: &APIServerAccessProfile{
AuthorizedIPRanges: []string{"192.168.0.1/32, 192.168.0.2/32, 192.168.0.3/32"},
},
Expand Down

0 comments on commit 6b286b9

Please sign in to comment.