Skip to content

Commit

Permalink
Fix some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
matthchr committed Jun 26, 2020
1 parent d961281 commit 33e8d06
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
3 changes: 1 addition & 2 deletions api/v1alpha1/eventhub_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ type EventHubStorageAccount struct {
// ResourceGroup - Name of the storage account resource group
// +kubebuilder:validation:Pattern=^[-\w\._\(\)]+$
// +kubebuilder:validation:MinLength:1
// +kubebuilder:validation:Required
ResourceGroup string `json:"resourceGroup"`
ResourceGroup string `json:"resourceGroup,omitempty"`
// AccountName - Name of the storage account
// +kubebuilder:validation:MaxLength=24
// +kubebuilder:validation:MinLength=3
Expand Down
2 changes: 2 additions & 0 deletions controllers/azuresqluser_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func TestAzureSQLUserControllerNoAdminSecret(t *testing.T) {
var sqlUser *azurev1alpha1.AzureSQLUser

sqlServerName = GenerateTestResourceNameWithRandom("sqlusr-test", 10)
resourceGroup := GenerateTestResourceNameWithRandom("myrg", 10)

username := "sql-test-user" + helpers.RandomString(10)
roles := []string{"db_owner"}
Expand All @@ -37,6 +38,7 @@ func TestAzureSQLUserControllerNoAdminSecret(t *testing.T) {
Namespace: "default",
},
Spec: azurev1alpha1.AzureSQLUserSpec{
ResourceGroup: resourceGroup,
Server: sqlServerName,
DbName: sqlDatabaseName,
AdminSecret: "",
Expand Down
10 changes: 6 additions & 4 deletions controllers/mysqluser_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func TestMySQLUserControllerNoAdminSecret(t *testing.T) {

mysqlServerName = GenerateTestResourceNameWithRandom("mysqlserver-test", 10)
mysqlDatabaseName = GenerateTestResourceNameWithRandom("mysqldb-test", 10)
resourceGroup := GenerateTestResourceNameWithRandom("myrg", 10)
mysqlusername := "mysql-test-user" + helpers.RandomString(10)
roles := []string{"select on *.* "}

Expand All @@ -37,10 +38,11 @@ func TestMySQLUserControllerNoAdminSecret(t *testing.T) {
Namespace: "default",
},
Spec: azurev1alpha1.MySQLUserSpec{
Server: mysqlServerName,
DbName: mysqlDatabaseName,
AdminSecret: "",
Roles: roles,
ResourceGroup: resourceGroup,
Server: mysqlServerName,
DbName: mysqlDatabaseName,
AdminSecret: "",
Roles: roles,
},
}

Expand Down
2 changes: 2 additions & 0 deletions controllers/postgresqluser_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func TestPostgreSQLUserControllerNoAdminSecret(t *testing.T) {

postgresqlServerName = GenerateTestResourceNameWithRandom("psqlserver-test", 10)
postgresqlDatabaseName = GenerateTestResourceNameWithRandom("psqldb-test", 10)
resourceGroup := GenerateTestResourceNameWithRandom("myrg", 10)
pusername := "psql-test-user" + helpers.RandomString(10)
roles := []string{"azure_pg_admin"}

Expand All @@ -37,6 +38,7 @@ func TestPostgreSQLUserControllerNoAdminSecret(t *testing.T) {
Namespace: "default",
},
Spec: azurev1alpha1.PostgreSQLUserSpec{
ResourceGroup: resourceGroup,
Server: postgresqlServerName,
DbName: postgresqlDatabaseName,
AdminSecret: "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ func (s *AzureSqlServerManager) Ensure(ctx context.Context, obj runtime.Object,

// TODO: This is a bit of a hack because really this check should be in the SDK.
// TODO: See: https://github.com/Azure/azure-sdk-for-go/issues/10712
// Note that this can really only happen due to bad state in etcd because the
// CRD for the resource requires this field. Bad state in etcd can be caused by
// something like conversion webhooks being disabled and using a non-storage
// version of the CRD. This is really just a nice-to-have error to make it clear
// what the problem is for that rare case, which primarily can happen while
// we are testing locally.
if instance.Spec.ResourceGroup == "" {
instance.Status.Message = "A non-empty resource group must be specified."
return false, nil
Expand Down

0 comments on commit 33e8d06

Please sign in to comment.