Merge "Fix mongodb database create"
This commit is contained in:
commit
b672ceab43
|
@ -699,8 +699,11 @@ class MongoDBAdmin(object):
|
|||
schema.check_create()
|
||||
LOG.debug('Creating MongoDB database %s', schema.name)
|
||||
db = admin_client[schema.name]
|
||||
db[tmp].insert({'dummy': True})
|
||||
db.drop_collection(tmp)
|
||||
# FIXME(songjian):can not create database with null content,
|
||||
# so create a collection
|
||||
# db[tmp].insert({'dummy': True})
|
||||
# db.drop_collection(tmp)
|
||||
db.create_collection(tmp)
|
||||
|
||||
def delete_database(self, database):
|
||||
"""Deletes the database."""
|
||||
|
|
|
@ -332,8 +332,11 @@ class GuestAgentMongoDBManagerTest(DatastoreManagerTest):
|
|||
|
||||
self.manager.create_database(self.context, [schema])
|
||||
|
||||
db_client['dummy'].insert.assert_called_with({'dummy': True})
|
||||
db_client.drop_collection.assert_called_with('dummy')
|
||||
# FIXME(songjian):can not create database with null content,
|
||||
# so create a collection
|
||||
# db_client['dummy'].insert.assert_called_with({'dummy': True})
|
||||
# db_client.drop_collection.assert_called_with('dummy')
|
||||
db_client.create_collection.assert_called_with('dummy')
|
||||
|
||||
@mock.patch.object(service, 'MongoDBClient')
|
||||
@mock.patch.object(service.MongoDBAdmin, '_admin_user')
|
||||
|
|
Loading…
Reference in New Issue