Skip to content

Commit 3406277

Browse files
committed
Moving out the rest of the storage integration tests
1 parent e91f114 commit 3406277

File tree

2 files changed

+166
-166
lines changed

2 files changed

+166
-166
lines changed

test/storage-integration-test.js

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,172 @@ TestStorage.prototype = {
262262
});
263263
});
264264
});
265+
266+
describe('#getBuildInfo', function() {
267+
describe('with invalid args', function() {
268+
it('should throw with non string id', function() {
269+
assert.throws(function() {
270+
return storage.getBuildInfo({
271+
project: 'project',
272+
build: 4
273+
});
274+
});
275+
});
276+
});
277+
278+
describe('with valid args', function() {
279+
var projectSettings;
280+
281+
beforeEach(function() {
282+
projectSettings = {};
283+
});
284+
285+
it('should reject non existent project', function() {
286+
return assert.isRejected(storage.getBuildInfo({
287+
project: 'project',
288+
build: 'foo'
289+
}));
290+
});
291+
292+
it('should reject non existent build', function() {
293+
return storage.createProject(projectSettings)
294+
.then(function(project) {
295+
return assert.isRejected(storage.getBuildInfo({
296+
project: project.project,
297+
build: 'foo'
298+
}), /Unknown Build/);
299+
});
300+
});
301+
302+
it('should return build info', function() {
303+
var buildOptions = {
304+
head: 'head',
305+
base: 'base',
306+
numBrowsers: 3
307+
};
308+
309+
var buildId;
310+
311+
return storage.createProject(projectSettings)
312+
.then(function(project) {
313+
buildOptions.project = project.project;
314+
315+
return storage.startBuild(buildOptions);
316+
})
317+
.then(function(data) {
318+
buildId = data.build;
319+
})
320+
.then(function() {
321+
return storage.getBuildInfo({
322+
project: buildOptions.project,
323+
build: buildId
324+
});
325+
})
326+
.then(function(data) {
327+
assert.isObject(data);
328+
assert.isString(data.build);
329+
assert.equal(data.status, 'pending');
330+
assert.isUndefined(data.project);
331+
332+
delete buildOptions.project;
333+
assert.shallowDeepEqual(data, buildOptions);
334+
});
335+
});
336+
});
337+
});
338+
339+
describe('#updateBuildInfo', function() {
340+
var projectId;
341+
var buildId;
342+
343+
beforeEach(function() {
344+
return storage.createProject({})
345+
.then(function(project) {
346+
projectId = project.project;
347+
})
348+
.then(function() {
349+
var buildOptions = {
350+
project: projectId,
351+
head: 'head',
352+
base: 'base',
353+
numBrowsers: 3
354+
};
355+
356+
return storage.startBuild(buildOptions);
357+
})
358+
.then(function(data) {
359+
buildId = data.build;
360+
});
361+
});
362+
363+
describe('with success', function() {
364+
beforeEach(function() {
365+
return storage.updateBuildInfo({
366+
project: projectId,
367+
build: buildId,
368+
status: 'success'
369+
});
370+
});
371+
372+
it('should write success', function() {
373+
return storage.getBuildInfo({
374+
project: projectId,
375+
build: buildId
376+
})
377+
.then(function(buildInfo) {
378+
assert.equal(buildInfo.status, 'success');
379+
});
380+
});
381+
382+
it('should not have diffs', function() {
383+
return storage.getBuildInfo({
384+
project: projectId,
385+
build: buildId
386+
})
387+
.then(function(buildInfo) {
388+
assert.isUndefined(buildInfo.diffs);
389+
});
390+
});
391+
});
392+
393+
describe('with failure', function() {
394+
var newBuildInfo;
395+
396+
beforeEach(function() {
397+
newBuildInfo = {
398+
project: projectId,
399+
build: buildId,
400+
status: 'failed',
401+
diffs: {
402+
Chrome: ['image1.png,', 'image2.png'],
403+
Firefox: ['image1.png']
404+
}
405+
};
406+
407+
return storage.updateBuildInfo(newBuildInfo);
408+
});
409+
410+
it('should write failure', function() {
411+
return storage.getBuildInfo({
412+
project: projectId,
413+
build: buildId
414+
})
415+
.then(function(buildInfo) {
416+
assert.equal(buildInfo.status, 'failed');
417+
});
418+
});
419+
420+
it('should have diffs', function() {
421+
return storage.getBuildInfo({
422+
project: projectId,
423+
build: buildId
424+
})
425+
.then(function(buildInfo) {
426+
assert.deepEqual(buildInfo.diffs, newBuildInfo.diffs);
427+
});
428+
});
429+
});
430+
});
265431
});
266432
}
267433
};

test/storage-test.js

Lines changed: 0 additions & 166 deletions
Original file line numberDiff line numberDiff line change
@@ -330,172 +330,6 @@ describe('module/storage', function() {
330330
});
331331
});
332332

333-
describe('#getBuildInfo', function() {
334-
describe('with invalid args', function() {
335-
it('should throw with non string id', function() {
336-
assert.throws(function() {
337-
return storage.getBuildInfo({
338-
project: 'project',
339-
build: 4
340-
});
341-
});
342-
});
343-
});
344-
345-
describe('with valid args', function() {
346-
var projectSettings;
347-
348-
beforeEach(function() {
349-
projectSettings = {};
350-
});
351-
352-
it('should reject non existent project', function() {
353-
return assert.isRejected(storage.getBuildInfo({
354-
project: 'project',
355-
build: 'foo'
356-
}));
357-
});
358-
359-
it('should reject non existent build', function() {
360-
return storage.createProject(projectSettings)
361-
.then(function(project) {
362-
return assert.isRejected(storage.getBuildInfo({
363-
project: project.project,
364-
build: 'foo'
365-
}), /Unknown Build/);
366-
});
367-
});
368-
369-
it('should return build info', function() {
370-
var buildOptions = {
371-
head: 'head',
372-
base: 'base',
373-
numBrowsers: 3
374-
};
375-
376-
var buildId;
377-
378-
return storage.createProject(projectSettings)
379-
.then(function(project) {
380-
buildOptions.project = project.project;
381-
382-
return storage.startBuild(buildOptions);
383-
})
384-
.then(function(data) {
385-
buildId = data.build;
386-
})
387-
.then(function() {
388-
return storage.getBuildInfo({
389-
project: buildOptions.project,
390-
build: buildId
391-
});
392-
})
393-
.then(function(data) {
394-
assert.isObject(data);
395-
assert.isString(data.build);
396-
assert.equal(data.status, 'pending');
397-
assert.isUndefined(data.project);
398-
399-
delete buildOptions.project;
400-
assert.shallowDeepEqual(data, buildOptions);
401-
});
402-
});
403-
});
404-
});
405-
406-
describe('#updateBuildInfo', function() {
407-
var projectId;
408-
var buildId;
409-
410-
beforeEach(function() {
411-
return storage.createProject({})
412-
.then(function(project) {
413-
projectId = project.project;
414-
})
415-
.then(function() {
416-
var buildOptions = {
417-
project: projectId,
418-
head: 'head',
419-
base: 'base',
420-
numBrowsers: 3
421-
};
422-
423-
return storage.startBuild(buildOptions);
424-
})
425-
.then(function(data) {
426-
buildId = data.build;
427-
});
428-
});
429-
430-
describe('with success', function() {
431-
beforeEach(function() {
432-
return storage.updateBuildInfo({
433-
project: projectId,
434-
build: buildId,
435-
status: 'success'
436-
});
437-
});
438-
439-
it('should write success', function() {
440-
return storage.getBuildInfo({
441-
project: projectId,
442-
build: buildId
443-
})
444-
.then(function(buildInfo) {
445-
assert.equal(buildInfo.status, 'success');
446-
});
447-
});
448-
449-
it('should not have diffs', function() {
450-
return storage.getBuildInfo({
451-
project: projectId,
452-
build: buildId
453-
})
454-
.then(function(buildInfo) {
455-
assert.isUndefined(buildInfo.diffs);
456-
});
457-
});
458-
});
459-
460-
describe('with failure', function() {
461-
var newBuildInfo;
462-
463-
beforeEach(function() {
464-
newBuildInfo = {
465-
project: projectId,
466-
build: buildId,
467-
status: 'failed',
468-
diffs: {
469-
Chrome: ['image1.png,', 'image2.png'],
470-
Firefox: ['image1.png']
471-
}
472-
};
473-
474-
return storage.updateBuildInfo(newBuildInfo);
475-
});
476-
477-
it('should write failure', function() {
478-
return storage.getBuildInfo({
479-
project: projectId,
480-
build: buildId
481-
})
482-
.then(function(buildInfo) {
483-
assert.equal(buildInfo.status, 'failed');
484-
});
485-
});
486-
487-
it('should have diffs', function() {
488-
return storage.getBuildInfo({
489-
project: projectId,
490-
build: buildId
491-
})
492-
.then(function(buildInfo) {
493-
assert.deepEqual(buildInfo.diffs, newBuildInfo.diffs);
494-
});
495-
});
496-
});
497-
});
498-
499333
describe('#getBrowsersForSha', function() {
500334
var project;
501335
var sha;

0 commit comments

Comments
 (0)