Skip to content

Commit 4f9ac01

Browse files
committed
test(privateLocation): add privateLocation to test
1 parent d338566 commit 4f9ac01

3 files changed

Lines changed: 24 additions & 6 deletions

File tree

external/checkly/group_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ import "testing"
2020

2121
func TestChecklyGroup(t *testing.T) {
2222
data := Group{
23-
Name: "foo",
24-
Locations: []string{"basement"},
23+
Name: "foo",
24+
Locations: []string{"basement"},
25+
PrivateLocations: []string{"ground-floor"},
2526
}
2627

2728
testData := checklyGroup(data)

internal/controller/checkly/group_controller_test.go

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ import (
2020
"time"
2121

2222
"github.com/checkly/checkly-go-sdk"
23-
checklyv1alpha1 "github.com/checkly/checkly-operator/api/checkly/v1alpha1"
2423
. "github.com/onsi/ginkgo"
2524
. "github.com/onsi/gomega"
2625
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2726
"k8s.io/apimachinery/pkg/types"
27+
28+
checklyv1alpha1 "github.com/checkly/checkly-operator/api/checkly/v1alpha1"
2829
)
2930

3031
var _ = Describe("ApiCheck Controller", func() {
@@ -51,6 +52,7 @@ var _ = Describe("ApiCheck Controller", func() {
5152
It("Full reconciliation", func() {
5253

5354
updatedLocations := []string{"eu-west-2", "eu-west-1"}
55+
updatedPrivateLocations := []string{"ground-floor"}
5456
groupKey := types.NamespacedName{
5557
Name: "test-group",
5658
}
@@ -64,8 +66,9 @@ var _ = Describe("ApiCheck Controller", func() {
6466
Name: groupKey.Name,
6567
},
6668
Spec: checklyv1alpha1.GroupSpec{
67-
Locations: []string{"eu-west-1"},
68-
AlertChannels: []string{alertChannelKey.Name},
69+
Locations: []string{"eu-west-1"},
70+
PrivateLocations: []string{},
71+
AlertChannels: []string{alertChannelKey.Name},
6972
},
7073
}
7174

@@ -140,6 +143,20 @@ var _ = Describe("ApiCheck Controller", func() {
140143
}
141144
}, timeout, interval).Should(BeTrue())
142145

146+
updated.Spec.PrivateLocations = updatedPrivateLocations
147+
Expect(k8sClient.Update(context.Background(), updated)).Should(Succeed())
148+
149+
By("Expecting update")
150+
Eventually(func() bool {
151+
f := &checklyv1alpha1.Group{}
152+
err := k8sClient.Get(context.Background(), groupKey, f)
153+
if len(f.Spec.PrivateLocations) == 1 && err == nil {
154+
return true
155+
} else {
156+
return false
157+
}
158+
}, timeout, interval).Should(BeTrue())
159+
143160
// Delete group
144161
By("Expecting to delete successfully")
145162
Eventually(func() error {

internal/controller/checkly/suite_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"os"
2323
"path/filepath"
2424
"testing"
25+
//+kubebuilder:scaffold:imports
2526

2627
"github.com/checkly/checkly-go-sdk"
2728
. "github.com/onsi/ginkgo"
@@ -35,7 +36,6 @@ import (
3536
"sigs.k8s.io/controller-runtime/pkg/log/zap"
3637

3738
checklyv1alpha1 "github.com/checkly/checkly-operator/api/checkly/v1alpha1"
38-
//+kubebuilder:scaffold:imports
3939
)
4040

4141
// These tests use Ginkgo (BDD-style Go testing framework). Refer to

0 commit comments

Comments
 (0)