Skip to content

Commit

Permalink
e2e test
Browse files Browse the repository at this point in the history
Signed-off-by: craig <[email protected]>
  • Loading branch information
maleck13 committed Aug 21, 2024
1 parent 5656b94 commit 55fb806
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion internal/controller/dnsrecord_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ var _ = Describe("DNSRecordReconciler", func() {

It("should assign the most suitable zone for the provider", func(ctx SpecContext) {
pSecret = pBuilder.
WithZonesInitialisedFor("example.com", "foo.example.com", "bar.foo.example.com").
WithZonesInitialisedFor("example.com", "foo.example.com").
Build()
Expect(k8sClient.Create(ctx, pSecret)).To(Succeed())

Expand Down Expand Up @@ -717,6 +717,43 @@ var _ = Describe("DNSRecordReconciler", func() {
}, TestTimeoutMedium, time.Second).Should(Succeed())
})

It("should report an error when an apex domain is used", func(ctx SpecContext) {
pSecret = pBuilder.
WithZonesInitialisedFor("example.com").
Build()
Expect(k8sClient.Create(ctx, pSecret)).To(Succeed())

dnsRecord = &v1alpha1.DNSRecord{
ObjectMeta: metav1.ObjectMeta{
Name: "example.com",
Namespace: testNamespace,
},
Spec: v1alpha1.DNSRecordSpec{
RootHost: "example.com",
ProviderRef: v1alpha1.ProviderRef{
Name: pSecret.Name,
},
Endpoints: getTestEndpoints("example.com", "127.0.0.1"),
},
}
Expect(k8sClient.Create(ctx, dnsRecord)).To(Succeed())
Eventually(func(g Gomega) {
err := k8sClient.Get(ctx, client.ObjectKeyFromObject(dnsRecord), dnsRecord)
g.Expect(err).NotTo(HaveOccurred())
g.Expect(dnsRecord.Status.ZoneID).To(BeEmpty())
g.Expect(dnsRecord.Status.ZoneDomainName).To(BeEmpty())
g.Expect(dnsRecord.Status.Conditions).To(
ContainElement(MatchFields(IgnoreExtras, Fields{
"Type": Equal(string(v1alpha1.ConditionTypeReady)),
"Status": Equal(metav1.ConditionFalse),
"Reason": Equal("DNSProviderError"),
"Message": ContainSubstring("is an apex domain"),
"ObservedGeneration": Equal(dnsRecord.Generation),
})),
)
}, TestTimeoutMedium, time.Second).Should(Succeed())
})

It("should update broken record when provider is updated", func(ctx SpecContext) {
pSecret = pBuilder.
WithZonesInitialisedFor("example.com").
Expand Down

0 comments on commit 55fb806

Please sign in to comment.