forked from Azure/azure-service-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmysqlserveradministrator_controller_test.go
77 lines (64 loc) · 2.49 KB
/
mysqlserveradministrator_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
77
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//go:build all || mysql || mysqlfirewallrule
// +build all mysql mysqlfirewallrule
package controllers
import (
"context"
"testing"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
azurev1alpha1 "github.com/Azure/azure-service-operator/api/v1alpha1"
"github.com/Azure/azure-service-operator/pkg/errhelp"
)
func TestMySQLAdministratorNoResourceGroup(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("mysqlsrv-rg", 10)
server := GenerateTestResourceNameWithRandom("mysqlsrv", 10)
adminName := GenerateTestResourceNameWithRandom("mysql-admin", 10)
// Create the admin object and expect the Reconcile to be created
adminInstance := &azurev1alpha1.MySQLServerAdministrator{
ObjectMeta: metav1.ObjectMeta{
Name: adminName,
Namespace: "default",
},
Spec: azurev1alpha1.MySQLServerAdministratorSpec{
ResourceGroup: rgName,
Server: server,
Login: "my-mi",
AdministratorType: azurev1alpha1.MySQLServerAdministratorTypeActiveDirectory,
Sid: "00000000-0000-0000-0000-000000000000",
TenantId: "00000000-0000-0000-0000-000000000000",
},
}
EnsureInstanceWithResult(ctx, t, tc, adminInstance, errhelp.ResourceGroupNotFoundErrorCode, false)
EnsureDelete(ctx, t, tc, adminInstance)
}
func TestMySQLAdministratorNoServer(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
server := GenerateTestResourceNameWithRandom("mysqlsrv-rg", 10)
adminName := GenerateTestResourceNameWithRandom("mysql-admin", 10)
// Create the admin object and expect the Reconcile to be created
adminInstance := &azurev1alpha1.MySQLServerAdministrator{
ObjectMeta: metav1.ObjectMeta{
Name: adminName,
Namespace: "default",
},
Spec: azurev1alpha1.MySQLServerAdministratorSpec{
ResourceGroup: rgName,
Server: server,
Login: "my-mi",
AdministratorType: azurev1alpha1.MySQLServerAdministratorTypeActiveDirectory,
Sid: "00000000-0000-0000-0000-000000000000",
TenantId: "00000000-0000-0000-0000-000000000000",
},
}
EnsureInstanceWithResult(ctx, t, tc, adminInstance, errhelp.ResourceNotFound, false)
EnsureDelete(ctx, t, tc, adminInstance)
}