Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nawazkh committed Oct 18, 2023
1 parent 04b8f41 commit 7893025
Showing 1 changed file with 24 additions and 17 deletions.
41 changes: 24 additions & 17 deletions azure/services/agentpools/spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ func sdkWithNodeTaints(nodeTaints *[]string) func(*containerservice.AgentPool) {
}
}

func sdkWithNodeLabels(nodeLabels map[string]*string) func(*armcontainerservice.AgentPool) {
return func(pool *armcontainerservice.AgentPool) {
pool.Properties.NodeLabels = nodeLabels
func sdkWithNodeLabels(nodeLabels map[string]*string) func(*containerservice.AgentPool) {
return func(pool *containerservice.AgentPool) {
pool.NodeLabels = nodeLabels
}
}

Expand Down Expand Up @@ -320,16 +320,16 @@ func TestParameters(t *testing.T) {
},
),
existing: sdkFakeAgentPool(
func(pool *armcontainerservice.AgentPool) {
pool.Properties.NodeLabels = map[string]*string{
"fake-label": ptr.To("fake-value"),
"kubernetes.azure.com/scalesetpriority": ptr.To("spot"),
func(pool *containerservice.AgentPool) {
pool.NodeLabels = map[string]*string{
"fake-label": pointer.String("fake-value"),
"kubernetes.azure.com/scalesetpriority": pointer.String("spot"),
}
},
sdkWithProvisioningState("Succeeded"),
),
expected: sdkFakeAgentPool(sdkWithNodeLabels(map[string]*string{
"kubernetes.azure.com/scalesetpriority": ptr.To("spot"),
"kubernetes.azure.com/scalesetpriority": pointer.String("spot"),
})),
expectedError: nil,
},
Expand All @@ -346,7 +346,10 @@ func TestParameters(t *testing.T) {
},
sdkWithProvisioningState("Succeeded"),
),
expected: sdkFakeAgentPool(sdkWithNodeTaints(make([]*string, 0))),
expected: sdkFakeAgentPool(sdkWithNodeTaints(
func() *[]string {
return &[]string{}
}())),
expectedError: nil,
},
{
Expand All @@ -373,15 +376,19 @@ func TestParameters(t *testing.T) {
},
),
existing: sdkFakeAgentPool(
func(pool *armcontainerservice.AgentPool) {
pool.Properties.NodeTaints = []*string{
ptr.To(azureutil.AzureSystemNodeLabelPrefix + "-fake-taint"),
ptr.To("fake-old-taint"),
func(pool *containerservice.AgentPool) {
dummyTaints := []string{
azureutil.AzureSystemNodeLabelPrefix + "-fake-taint",
"fake-old-taint",
}
pool.NodeTaints = &dummyTaints
},
sdkWithProvisioningState("Succeeded"),
),
expected: sdkFakeAgentPool(sdkWithNodeTaints([]*string{ptr.To(azureutil.AzureSystemNodeLabelPrefix + "-fake-taint")})),
expected: sdkFakeAgentPool(sdkWithNodeTaints(func() *[]string {
dummy := []string{azureutil.AzureSystemNodeLabelPrefix + "-fake-taint"}
return &dummy
}())),
expectedError: nil,
},
{
Expand Down Expand Up @@ -429,7 +436,7 @@ func TestParameters(t *testing.T) {
func(pool *AgentPoolSpec) { pool.NodeLabels = nil },
),
existing: sdkFakeAgentPool(
func(pool *armcontainerservice.AgentPool) { pool.Properties.NodeLabels = nil },
func(pool *containerservice.AgentPool) { pool.NodeLabels = nil },
sdkWithProvisioningState("Succeeded"),
),
expected: nil,
Expand Down Expand Up @@ -497,8 +504,8 @@ func TestMergeSystemNodeLabels(t *testing.T) {
name: "labels are nil when both the capz and aks labels are nil",
capzLabels: nil,
aksLabels: map[string]*string{
"foo": ptr.To("bar"),
"hello": ptr.To("world"),
"foo": pointer.String("bar"),
"hello": pointer.String("world"),
},
expected: map[string]*string{},
},
Expand Down

0 comments on commit 7893025

Please sign in to comment.