Skip to content

Commit

Permalink
feat: export datamanager CMS-2730
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-scherzinger committed Apr 19, 2017
1 parent 861f139 commit 75df67f
Show file tree
Hide file tree
Showing 4 changed files with 223 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/resources/datamanager/DataManagerResource.js
Expand Up @@ -615,4 +615,19 @@ export default class DataManagerResource extends Resource {
return () => this.assetList({ filter: { assetID: { any: urls } } });
});
}

/**
* Export this datamanager as postman collection.
*
* @returns {Promise<object>} The exported datamanager with collection and dataSchema.
*/
export() {
return Promise.resolve()
.then(() => {
const request = this.newRequest()
.follow('ec:datamananger/export');
return get(this.environment, request);
})
.then(([res]) => res);
}
}
16 changes: 16 additions & 0 deletions test/datamanager/DataManager.test.js
Expand Up @@ -920,4 +920,20 @@ describe('DataManager Resource', () => {
return resource.createAssets([[]]).should.be.rejectedWith('Cannot handle input.')
.notify(() => stubGetUrl.restore());
});

it('should export datamanager', () => {
const stub = sinon.stub(helper, 'get');
stub.returns(resolver('dm-export.json'));

return resource.export()
.then((exported) => {
exported.should.have.property('collection');
exported.should.have.property('dataSchema');
stub.restore();
})
.catch((err) => {
stub.restore();
throw err;
});
});
});

0 comments on commit 75df67f

Please sign in to comment.