Skip to content

Commit

Permalink
COMPASS-213: Pass readonly options to collections (#106)
Browse files Browse the repository at this point in the history
* COMPASS-213: Pass readonly options to collections

* COMPASS-213: Fix tests, bump collection model
  • Loading branch information
durran committed Nov 11, 2016
1 parent 67947a3 commit 7eef62d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
3 changes: 2 additions & 1 deletion packages/instance-model/lib/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,8 @@ function parseCollection(resp) {
return {
_id: ns.toString(),
name: ns.collection,
database: ns.database
database: ns.database,
readonly: _.get(resp, 'info.readOnly', false)
};
}

Expand Down
2 changes: 1 addition & 1 deletion packages/instance-model/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"async": "^1.5.2",
"debug": "^2.2.0",
"lodash": "^4.10.0",
"mongodb-collection-model": "^0.3.0",
"mongodb-collection-model": "^0.3.1",
"mongodb-database-model": "^0.1.2",
"mongodb-js-errors": "^0.2.1",
"mongodb-ns": "^1.0.1",
Expand Down
20 changes: 14 additions & 6 deletions packages/instance-model/test/fetch-mocked.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ describe('fetch-mocked', function() {
{
'_id': 'tenants.mongodb',
'database': 'tenants',
'name': 'mongodb'
'name': 'mongodb',
'readonly': false
}
];
assert.deepEqual(res, expected);
Expand Down Expand Up @@ -257,7 +258,10 @@ describe('fetch-mocked', function() {
it('should lists all collections for each listable db', function(done) {
results.userInfo = fixtures.USER_INFO_JOHN;
results.db = makeMockDB(null, [{
'name': 'testCol'
'name': 'testCol',
'info': {
'readOnly': true
}
}]);

fetch.listCollections(function(err, res) {
Expand All @@ -267,22 +271,26 @@ describe('fetch-mocked', function() {
{
'_id': 'accounts.testCol',
'database': 'accounts',
'name': 'testCol'
'name': 'testCol',
'readonly': true
},
{
'_id': 'products.testCol',
'database': 'products',
'name': 'testCol'
'name': 'testCol',
'readonly': true
},
{
'_id': 'reporting.testCol',
'database': 'reporting',
'name': 'testCol'
'name': 'testCol',
'readonly': true
},
{
'_id': 'sales.testCol',
'database': 'sales',
'name': 'testCol'
'name': 'testCol',
'readonly': true
}
];
expected.sort();
Expand Down

0 comments on commit 7eef62d

Please sign in to comment.