Skip to content

Commit

Permalink
Merge branch 'master' into mysql-replica
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamMortlMicrosoft authored Apr 16, 2020
2 parents e2157be + 2d608ac commit 6480335
Showing 1 changed file with 68 additions and 1 deletion.
69 changes: 68 additions & 1 deletion controllers/cosmosdb_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestCosmosDBHappyPath(t *testing.T) {
Namespace: cosmosDBNamespace,
},
Spec: v1alpha1.CosmosDBSpec{
Location: "westus",
Location: tc.resourceGroupLocation,
ResourceGroup: tc.resourceGroupName,
Kind: v1alpha1.CosmosDBKindGlobalDocumentDB,
Properties: v1alpha1.CosmosDBProperties{
Expand All @@ -42,3 +42,70 @@ func TestCosmosDBHappyPath(t *testing.T) {
EnsureDelete(ctx, t, tc, dbInstance)

}

func TestCosmosDBControllerNoResourceGroup(t *testing.T) {
t.Parallel()
defer PanicRecover(t)
ctx := context.Background()

rgLocation := tc.resourceGroupLocation
//wrong resource group name
resourceGroupName := "gone"

cosmosDBAccountName := GenerateTestResourceNameWithRandom("cosmosdb", 8)
cosmosDBNamespace := "default"

dbInstance1 := &v1alpha1.CosmosDB{
ObjectMeta: metav1.ObjectMeta{
Name: cosmosDBAccountName,
Namespace: cosmosDBNamespace,
},
Spec: v1alpha1.CosmosDBSpec{
Location: rgLocation,
ResourceGroup: resourceGroupName,
Kind: v1alpha1.CosmosDBKindGlobalDocumentDB,
Properties: v1alpha1.CosmosDBProperties{
DatabaseAccountOfferType: v1alpha1.CosmosDBDatabaseAccountOfferTypeStandard,
},
},
}
//the expected error meessage to be shown
errMessage := "Waiting for resource group '" + resourceGroupName + "' to be available"

EnsureInstanceWithResult(ctx, t, tc, dbInstance1, errMessage, false)
EnsureDelete(ctx, t, tc, dbInstance1)
}

func TestCosmosDBControllerInvalidLocation(t *testing.T) {
t.Parallel()
defer PanicRecover(t)
ctx := context.Background()

resourceGroupName := tc.resourceGroupName
//rglocation doesnot exist
rgLocation := GenerateTestResourceNameWithRandom("cosmos-lo", 10)

cosmosDBAccountName := GenerateTestResourceNameWithRandom("cosmos-db", 8)
cosmosDBNamespace := "default"

dbInstance2 := &v1alpha1.CosmosDB{
ObjectMeta: metav1.ObjectMeta{
Name: cosmosDBAccountName,
Namespace: cosmosDBNamespace,
},
Spec: v1alpha1.CosmosDBSpec{
Location: rgLocation,
ResourceGroup: resourceGroupName,
Kind: v1alpha1.CosmosDBKindGlobalDocumentDB,
Properties: v1alpha1.CosmosDBProperties{
DatabaseAccountOfferType: v1alpha1.CosmosDBDatabaseAccountOfferTypeStandard,
},
},
}

//error meessage to be expected
errMessage := "The specified location '" + rgLocation + "' is invalid"

EnsureInstanceWithResult(ctx, t, tc, dbInstance2, errMessage, false)
EnsureDelete(ctx, t, tc, dbInstance2)
}

0 comments on commit 6480335

Please sign in to comment.