forked from Azure/azure-service-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpostgresqlfirewallrule_controller_test.go
76 lines (60 loc) · 2.37 KB
/
postgresqlfirewallrule_controller_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//go:build all || psqlfirewallrule
// +build all psqlfirewallrule
package controllers
import (
"context"
"testing"
azurev1alpha1 "github.com/Azure/azure-service-operator/api/v1alpha1"
"github.com/Azure/azure-service-operator/pkg/errhelp"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
func TestPSQLFirewallRuleControllerNoResourceGroup(t *testing.T) {
t.Parallel()
defer PanicRecover(t)
ctx := context.Background()
// Add any setup steps that needs to be executed before each test
rgName := GenerateTestResourceNameWithRandom("psqlsrv-rg", 10)
postgreSQLServerName := GenerateTestResourceNameWithRandom("psql-srv", 10)
postgreSQLFirewallRuleName := GenerateTestResourceNameWithRandom("psql-fwrule", 10)
// Create the PostgreSQLFirewallRule object and expect the Reconcile to be created
postgreSQLFirewallRuleInstance := &azurev1alpha1.PostgreSQLFirewallRule{
ObjectMeta: metav1.ObjectMeta{
Name: postgreSQLFirewallRuleName,
Namespace: "default",
},
Spec: azurev1alpha1.PostgreSQLFirewallRuleSpec{
ResourceGroup: rgName,
Server: postgreSQLServerName,
StartIPAddress: "0.0.0.0",
EndIPAddress: "0.0.0.0",
},
}
EnsureInstanceWithResult(ctx, t, tc, postgreSQLFirewallRuleInstance, errhelp.ResourceGroupNotFoundErrorCode, false)
EnsureDelete(ctx, t, tc, postgreSQLFirewallRuleInstance)
}
func TestPSQLFirewallRuleControllerNoServer(t *testing.T) {
t.Parallel()
defer PanicRecover(t)
ctx := context.Background()
// Add any setup steps that needs to be executed before each test
rgName := tc.resourceGroupName
postgreSQLServerName := GenerateTestResourceNameWithRandom("psql-srv", 10)
postgreSQLFirewallRuleName := GenerateTestResourceNameWithRandom("psql-fwrule", 10)
// Create the PostgreSQLFirewallRule object and expect the Reconcile to be created
postgreSQLFirewallRuleInstance := &azurev1alpha1.PostgreSQLFirewallRule{
ObjectMeta: metav1.ObjectMeta{
Name: postgreSQLFirewallRuleName,
Namespace: "default",
},
Spec: azurev1alpha1.PostgreSQLFirewallRuleSpec{
ResourceGroup: rgName,
Server: postgreSQLServerName,
StartIPAddress: "0.0.0.0",
EndIPAddress: "0.0.0.0",
},
}
EnsureInstanceWithResult(ctx, t, tc, postgreSQLFirewallRuleInstance, errhelp.ResourceNotFound, false)
EnsureDelete(ctx, t, tc, postgreSQLFirewallRuleInstance)
}