Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor username/password into options in databases CRUD
- Loading branch information
Showing
3 changed files
with
104 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,84 @@ | ||
var Errors = require('../../lib/errors'); | ||
describe("Client API", function () { | ||
|
||
before(CAN_RUN(37, function () { | ||
|
||
})) | ||
it('should create and connect the client', function (done) { | ||
var Errors = require("../../lib/errors"); | ||
describe("Client API", function() { | ||
before(CAN_RUN(37, function() {})); | ||
it("should create and connect the client", function(done) { | ||
this.client = new global.CLIENT(TEST_SERVER_CONFIG); | ||
this.client.connect() | ||
.then(() => { | ||
done(0); | ||
}) | ||
this.client.connect().then(() => { | ||
done(0); | ||
}); | ||
}); | ||
|
||
it('should fail to connect the client', function () { | ||
this.client = new global.CLIENT(Object.assign({}, TEST_SERVER_CONFIG, { | ||
port: 3535, | ||
pool: { | ||
acquireTimeoutMillis: 100 | ||
} | ||
})); | ||
return this.client.connect() | ||
it("should fail to connect the client", function() { | ||
this.client = new global.CLIENT( | ||
Object.assign({}, TEST_SERVER_CONFIG, { | ||
port: 3535, | ||
pool: { | ||
acquireTimeoutMillis: 100 | ||
} | ||
}) | ||
); | ||
return this.client | ||
.connect() | ||
.then(() => { | ||
throw new Error('Should never happen!'); | ||
}).catch(err => { | ||
err.should.be.an.instanceOf(Errors.Connection); | ||
throw new Error("Should never happen!"); | ||
}) | ||
.catch(err => { | ||
err.should.be.an.instanceOf(Errors.Connection); | ||
}); | ||
}); | ||
|
||
it('should connect the client with multiple servers', function (done) { | ||
it("should connect the client with multiple servers", function(done) { | ||
var config = Object.assign({}, TEST_SERVER_CONFIG, { | ||
port: 3535, | ||
pool: { | ||
acquireTimeoutMillis: 100 | ||
}, | ||
servers: [TEST_SERVER_CONFIG] | ||
}) | ||
}); | ||
this.client = new global.CLIENT(config); | ||
this.client.connect().then(() => { | ||
done(); | ||
}).catch(err => { | ||
throw new Error('Should never happen!'); | ||
}) | ||
this.client | ||
.connect() | ||
.then(() => { | ||
done(); | ||
}) | ||
.catch(err => { | ||
throw new Error("Should never happen!"); | ||
}); | ||
}); | ||
|
||
it('should connect the client and create/drop a database', function () { | ||
it("should connect the client and create/drop a database", function() { | ||
this.client = new global.CLIENT(TEST_SERVER_CONFIG); | ||
var dbConfig = {name: "client_test_db_create", storage: "memory"}; | ||
return this.client.connect() | ||
var dbConfig = { | ||
name: "client_test_db_create", | ||
storage: "memory", | ||
username: TEST_SERVER_CONFIG.username, | ||
password: TEST_SERVER_CONFIG.password | ||
}; | ||
return this.client | ||
.connect() | ||
.then(() => { | ||
return this.client.createDatabase(TEST_SERVER_CONFIG.username, TEST_SERVER_CONFIG.password, dbConfig); | ||
return this.client.createDatabase( | ||
dbConfig | ||
); | ||
}) | ||
.then(() => { | ||
return this.client.existsDatabase(TEST_SERVER_CONFIG.username, TEST_SERVER_CONFIG.password, dbConfig); | ||
return this.client.existsDatabase( | ||
dbConfig | ||
); | ||
}) | ||
.then((response) => { | ||
.then(response => { | ||
response.should.be.eql(true); | ||
return this.client.dropDatabase(TEST_SERVER_CONFIG.username, TEST_SERVER_CONFIG.password, dbConfig); | ||
return this.client.dropDatabase( | ||
dbConfig | ||
); | ||
}) | ||
.then(() => { | ||
return this.client.existsDatabase(TEST_SERVER_CONFIG.username, TEST_SERVER_CONFIG.password, dbConfig); | ||
return this.client.existsDatabase( | ||
dbConfig | ||
); | ||
}) | ||
.then((response) => { | ||
.then(response => { | ||
response.should.be.eql(false); | ||
}) | ||
}); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters