Skip to content

Commit

Permalink
Merge pull request #162 from screwdriver-cd/add-collections-list
Browse files Browse the repository at this point in the history
fix(collections): Add list schema for collections
  • Loading branch information
minzcmu authored Jul 20, 2017
2 parents 99037da + 8dd2c8e commit c1412e3
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
13 changes: 13 additions & 0 deletions models/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@ module.exports = {
'description'
])).label('Get collection'),

/**
* Properties for collections that will come back during a LIST request.
* The LIST request will list all of the requesting user's collections.
*/
list: Joi.array().items(Joi.object(mutate(MODEL, [
'id',
'name',
'pipelineIds',
'userId'
], [
'description'
]))).label('List collections for requesting user'),

/**
* Properties for Collection that will be passed during a CREATE request
*
Expand Down
15 changes: 15 additions & 0 deletions test/data/collection.list.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
- id: 12
name: 'collection1'
description: 'pipelines for collection 1'
pipelineIds: [11, 12, 13]
userId: 123
- id: 13
name: 'collection2'
description: 'pipelines for collection 2'
pipelineIds: [14, 15, 16]
userId: 123
- id: 14
name: 'collection3'
description: 'pipelines for collection 3'
pipelineIds: [17, 18, 19]
userId: 123
10 changes: 10 additions & 0 deletions test/models/collection.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ describe('collection template', () => {
});
});

describe('list', () => {
it('validates the list', () => {
assert.isNull(validate('collection.list.yaml', models.collection.list).error);
});

it('fails the list', () => {
assert.isNotNull(validate('empty.yaml', models.collection.list).error);
});
});

describe('create', () => {
it('validates the create', () => {
assert.isNull(validate('collection.create.yaml', models.collection.create).error);
Expand Down

0 comments on commit c1412e3

Please sign in to comment.