Skip to content

Commit

Permalink
Merge branch 'master' into prd-sampleStore-flipflop
Browse files Browse the repository at this point in the history
  • Loading branch information
annyhe committed Apr 12, 2017
2 parents 960f8e9 + 12502ab commit 8572f23
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/cache/models/samples/patch.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,23 @@ describe(`api: redisStore: PATCH ${path}`, () => {
after(() => tu.toggleOverride('enableRedisSampleStore', false));

describe('Lists: ', () => {
it('reject if name is in request body', (done) => {
api.patch(`${path}/${sampleName}`)
.set('Authorization', token)
.send({ name: '3' })
.expect(constants.httpStatus.BAD_REQUEST)
.end((err, res) => {
if (err) {
done(err);
}

const error = res.body.errors[0];
expect(error.type).to.equal('ValidationError');
expect(error.description).to.contain('name');
done();
});
});

it('basic patch does not return id', (done) => {
api.patch(`${path}/${sampleName}`)
.set('Authorization', token)
Expand Down
18 changes: 18 additions & 0 deletions tests/cache/models/samples/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,24 @@ describe(`api: redisStore: POST ${path}`, () => {
});
});

it('reject if name is in request body', (done) => {
sampleToPost.name = '!#@#$%^&';
api.post(path)
.set('Authorization', token)
.send(sampleToPost)
.expect(constants.httpStatus.BAD_REQUEST)
.end((err, res) => {
if (err) {
done(err);
}

const error = res.body.errors[0];
expect(error.type).to.equal('ValidationError');
expect(error.description).to.contain('name');
done();
});
});

it('basic post /samples', (done) => {
api.post(path)
.set('Authorization', token)
Expand Down
17 changes: 17 additions & 0 deletions tests/cache/models/samples/put.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,23 @@ describe(`api: cache: PUT ${path}`, () => {
after(() => tu.toggleOverride('enableRedisSampleStore', false));

describe('Lists: ', () => {
it('reject if name is in request body', (done) => {
api.put(`${path}/${sampleName}`)
.set('Authorization', token)
.send({ name: '3' })
.expect(constants.httpStatus.BAD_REQUEST)
.end((err, res) => {
if (err) {
done(err);
}

const error = res.body.errors[0];
expect(error.type).to.equal('ValidationError');
expect(error.description).to.contain('name');
done();
});
});

it('basic put does not return id', (done) => {
api.put(`${path}/${sampleName}`)
.set('Authorization', token)
Expand Down
20 changes: 20 additions & 0 deletions tests/cache/models/samples/upsert.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,26 @@ describe(`api::redisEnabled::POST::upsert ${path}`, () => {
});
});

it('name field is required', (done) => {
api.post(path)
.set('Authorization', token)
.send({
value: '2',
})
.expect(constants.httpStatus.BAD_REQUEST)
.end((err, res) => {
if (err) {
done(err);
}

const error = res.body.errors[0];
expect(error.message).to.contain('name');
expect(error.type)
.to.equal(tu.schemaValidationErrorName);
done();
});
});

it('upsert succeeds when the sample does not exist', (done) => {
api.post(path)
.set('Authorization', token)
Expand Down
26 changes: 26 additions & 0 deletions tests/cache/models/samples/upsertBulk.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,32 @@ describe('api::redisEnabled::POST::bulkUpsert ' + path, () => {
after(rtu.forceDelete);
after(() => tu.toggleOverride('enableRedisSampleStore', false));

it('name field is required', (done) => {
const samp1Name = `${tu.namePrefix}Subject|${tu.namePrefix}Aspect1`;
const samp2Name = `${tu.namePrefix}Subject|${tu.namePrefix}Aspect2`
api.post(path)
.set('Authorization', token)
.send([
{
value: '0',
}, {
value: '20',
},
])
.expect(constants.httpStatus.BAD_REQUEST)
.end((err, res) => {
if (err) {
done(err);
}

const error = res.body.errors[0];
expect(error.message).to.contain('name');
expect(error.type)
.to.equal(tu.schemaValidationErrorName);
done();
});
});

it('all succeed', (done) => {
const samp1Name = `${tu.namePrefix}Subject|${tu.namePrefix}Aspect1`;
const samp2Name = `${tu.namePrefix}Subject|${tu.namePrefix}Aspect2`
Expand Down

0 comments on commit 8572f23

Please sign in to comment.