Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
njuettner committed Sep 10, 2024
1 parent de056d9 commit 78b0235
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions pkg/privatelinks/scope_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ var _ = Describe("Scope", func() {
})

Describe("looking up a private link with its resource ID", func() {
var privateLinkNames []string
var privateLinkNames []*string
var scope *privatelinks.Scope

JustBeforeEach(func() {
azureClusterBuilder := testhelpers.NewAzureClusterBuilder(subscriptionID, resourceGroup)
for _, privateLinkName := range privateLinkNames {
azureClusterBuilder.WithPrivateLink(testhelpers.NewPrivateLinkBuilder(privateLinkName).Build())
azureClusterBuilder.WithPrivateLink(testhelpers.NewPrivateLinkBuilder(*privateLinkName).Build())
}
azureCluster := azureClusterBuilder.Build()
capzSchema, err := capz.SchemeBuilder.Build()
Expand All @@ -83,8 +83,9 @@ var _ = Describe("Scope", func() {

When("AzureCluster has one private link", func() {
BeforeEach(func() {
privateLinkNames = []string{
"test-private-link",
linkName := "test-private-link"
privateLinkNames = []*string{
&linkName,
}
})

Expand All @@ -93,10 +94,10 @@ var _ = Describe("Scope", func() {
"/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/privateLinkServices/%s",
subscriptionID,
resourceGroup,
privateLinkNames[0])
*privateLinkNames[0])
privateLink, ok := scope.LookupPrivateLink(privateLinkID)
Expect(ok).To(BeTrue())
Expect(privateLink.Name).To(Equal(privateLinkNames[0]))
Expect(privateLink.Name).To(Equal(*privateLinkNames[0]))
})

It("doesn't find the private link when looking up with an incorrect resource ID", func() {
Expand All @@ -112,9 +113,11 @@ var _ = Describe("Scope", func() {

When("AzureCluster has multiple private links", func() {
BeforeEach(func() {
privateLinkNames = []string{
"test-private-link-1",
"test-private-link-2",
linkName1 := "test-private-link-1"
linkName2 := "test-private-link-2"
privateLinkNames = []*string{
&linkName1,
&linkName2,
}
})

Expand All @@ -124,10 +127,10 @@ var _ = Describe("Scope", func() {
"/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/privateLinkServices/%s",
subscriptionID,
resourceGroup,
privateLinkName)
*privateLinkName)
privateLink, ok := scope.LookupPrivateLink(privateLinkID)
Expect(ok).To(BeTrue())
Expect(privateLink.Name).To(Equal(privateLinkName))
Expect(privateLink.Name).To(Equal(*privateLinkName))
}
})
})
Expand Down Expand Up @@ -172,7 +175,7 @@ var _ = Describe("Scope", func() {
privateLinks := scope.GetPrivateLinksWithAllowedSubscription(subscriptionID)
Expect(privateLinks).To(HaveLen(1))
Expect(privateLinks[0].Name).To(Equal(privateLinkName))
Expect(privateLinks[0].AllowedSubscriptions).To(Equal(privateLinksWithAllowedSubscriptions[privateLinkName]))
Expect(privateLinks[0].AllowedSubscriptions).To(ConsistOf(&subscriptionID))
})

It("doesn't get a private link for the disallowed subscription ID", func() {
Expand All @@ -199,7 +202,7 @@ var _ = Describe("Scope", func() {
privateLinks := scope.GetPrivateLinksWithAllowedSubscription(subscriptionID)
Expect(privateLinks).To(HaveLen(1))
Expect(privateLinks[0].Name).To(Equal(privateLinkName))
Expect(privateLinks[0].AllowedSubscriptions).To(Equal(privateLinksWithAllowedSubscriptions[privateLinkName]))
Expect(privateLinks[0].AllowedSubscriptions).To(ConsistOf(&subscriptionID))
})
})
})
Expand Down

0 comments on commit 78b0235

Please sign in to comment.