mirror of
https://github.com/pikami/cosmium.git
synced 2025-12-20 01:10:44 +00:00
Fix database and collection deletion
This commit is contained in:
@@ -121,5 +121,26 @@ func Test_Collections(t *testing.T) {
|
||||
panic(err)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("Should delete collection with exactly matching name", func(t *testing.T) {
|
||||
ts.DataStore.CreateCollection(testDatabaseName, datastore.Collection{
|
||||
ID: testCollectionName + "extra",
|
||||
})
|
||||
ts.DataStore.CreateCollection(testDatabaseName, datastore.Collection{
|
||||
ID: testCollectionName,
|
||||
})
|
||||
|
||||
collectionResponse, err := databaseClient.NewContainer(testCollectionName)
|
||||
assert.Nil(t, err)
|
||||
|
||||
readResponse, err := collectionResponse.Delete(context.TODO(), &azcosmos.DeleteContainerOptions{})
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, readResponse.RawResponse.StatusCode, http.StatusNoContent)
|
||||
|
||||
collections, status := ts.DataStore.GetAllCollections(testDatabaseName)
|
||||
assert.Equal(t, status, datastore.StatusOk)
|
||||
assert.Len(t, collections, 1)
|
||||
assert.Equal(t, collections[0].ID, testCollectionName+"extra")
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@@ -109,5 +109,26 @@ func Test_Databases(t *testing.T) {
|
||||
panic(err)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("Should delete database with exactly matching name", func(t *testing.T) {
|
||||
ts.DataStore.CreateDatabase(datastore.Database{
|
||||
ID: testDatabaseName + "extra",
|
||||
})
|
||||
ts.DataStore.CreateDatabase(datastore.Database{
|
||||
ID: testDatabaseName,
|
||||
})
|
||||
|
||||
databaseResponse, err := client.NewDatabase(testDatabaseName)
|
||||
assert.Nil(t, err)
|
||||
|
||||
readResponse, err := databaseResponse.Delete(context.TODO(), &azcosmos.DeleteDatabaseOptions{})
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, readResponse.RawResponse.StatusCode, http.StatusNoContent)
|
||||
|
||||
dbs, status := ts.DataStore.GetAllDatabases()
|
||||
assert.Equal(t, status, datastore.StatusOk)
|
||||
assert.Len(t, dbs, 1)
|
||||
assert.Equal(t, dbs[0].ID, testDatabaseName+"extra")
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@@ -425,7 +425,7 @@ func Test_Documents(t *testing.T) {
|
||||
assert.Equal(t, int32(http.StatusNoContent), operationResponse.StatusCode)
|
||||
|
||||
_, status := ts.DataStore.GetDocument(testDatabaseName, testCollectionName, "12345")
|
||||
assert.Equal(t, datastore.StatusNotFound, int(status))
|
||||
assert.Equal(t, datastore.StatusNotFound, status)
|
||||
})
|
||||
|
||||
t.Run("Should execute REPLACE transactional batch", func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user