|
2 | 2 | var test = require('./shared').assert;
|
3 | 3 | var setupDatabase = require('./shared').setupDatabase;
|
4 | 4 | var f = require('util').format;
|
| 5 | +var expect = require('chai').expect; |
5 | 6 |
|
6 | 7 | describe('Operation Examples', function() {
|
7 | 8 | before(function() {
|
@@ -4822,7 +4823,7 @@ describe('Operation Examples', function() {
|
4822 | 4823 | * @example-method dropDatabase
|
4823 | 4824 | * @ignore
|
4824 | 4825 | */
|
4825 |
| - it('shouldCorrectlyDropTheDatabase', { |
| 4826 | + it('should correctly drop the database', { |
4826 | 4827 | metadata: { requires: { topology: ['single'] } },
|
4827 | 4828 |
|
4828 | 4829 | // The actual test we wish to run
|
@@ -5436,7 +5437,7 @@ describe('Operation Examples', function() {
|
5436 | 5437 | * @example-method listDatabases
|
5437 | 5438 | * @ignore
|
5438 | 5439 | */
|
5439 |
| - it('shouldCorrectlyListAllAvailableDatabases', { |
| 5440 | + it('should correctly list all available databases', { |
5440 | 5441 | metadata: {
|
5441 | 5442 | requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] }
|
5442 | 5443 | },
|
@@ -5472,6 +5473,52 @@ describe('Operation Examples', function() {
|
5472 | 5473 | }
|
5473 | 5474 | });
|
5474 | 5475 |
|
| 5476 | + it('should correctly list all available databases names and no database sizes', { |
| 5477 | + metadata: { |
| 5478 | + requires: { |
| 5479 | + topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'], |
| 5480 | + mongodb: '>=3.2.13' |
| 5481 | + } |
| 5482 | + }, |
| 5483 | + |
| 5484 | + // The actual test we wish to run |
| 5485 | + test: function(done) { |
| 5486 | + var configuration = this.configuration; |
| 5487 | + var client = configuration.newClient(configuration.writeConcernMax(), { poolSize: 1 }); |
| 5488 | + client.connect(function(err, client) { |
| 5489 | + // LINE var MongoClient = require('mongodb').MongoClient, |
| 5490 | + // LINE test = require('assert'); |
| 5491 | + // LINE MongoClient.connect('mongodb://localhost:27017/test', function(err, client) { |
| 5492 | + // LINE var db = client.db('test); |
| 5493 | + // REPLACE configuration.writeConcernMax() WITH {w:1} |
| 5494 | + // REMOVE-LINE restartAndDone |
| 5495 | + // REMOVE-LINE done(); |
| 5496 | + // REMOVE-LINE var db = client.db(configuration.db); |
| 5497 | + // BEGIN |
| 5498 | + var db = client.db(configuration.db); |
| 5499 | + // Use the admin database for the operation |
| 5500 | + var adminDb = db.admin(); |
| 5501 | + |
| 5502 | + // List all the available databases |
| 5503 | + adminDb.listDatabases({ nameOnly: 1 }, function(err, dbs) { |
| 5504 | + expect(err).to.not.exist; |
| 5505 | + expect(dbs.databases).to.include.deep.members([ |
| 5506 | + { |
| 5507 | + name: 'admin' |
| 5508 | + }, |
| 5509 | + { |
| 5510 | + name: 'local' |
| 5511 | + } |
| 5512 | + ]); |
| 5513 | + |
| 5514 | + client.close(); |
| 5515 | + done(); |
| 5516 | + }); |
| 5517 | + }); |
| 5518 | + // END |
| 5519 | + } |
| 5520 | + }); |
| 5521 | + |
5475 | 5522 | /**
|
5476 | 5523 | * Retrieve the current server Info
|
5477 | 5524 | *
|
|
0 commit comments