Skip to content

Commit

Permalink
Merging master into branch: test-bot-branch
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonolmstead33 authored Dec 15, 2016
2 parents 528ad45 + 5af68d7 commit 99e76fb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
22 changes: 11 additions & 11 deletions src/mgr.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function getDeployedVersion(build) {
}

function requestDeploy(build) {
return State.getBranchesInStates(stateMap.requestable)
return State.getBranchesInStates(build.repo, stateMap.requestable)
.then(function (data) {
if (data && data.items && data.items.length === 0) {
return State.create({
Expand All @@ -39,8 +39,8 @@ function requestDeploy(build) {
});
}

function startDeploy() {
return State.getBranchesInStates(stateMap.startable)
function startDeploy(build) {
return State.getBranchesInStates(build.repo, stateMap.startable)
.then(function (data) {
if (data && data.items && data.items.length > 0) {
return State.update({
Expand All @@ -53,8 +53,8 @@ function startDeploy() {
});
}

function finishDeploy() {
return State.getBranchesInStates(stateMap.finishable)
function finishDeploy(build) {
return State.getBranchesInStates(build.repo, stateMap.finishable)
.then(function (data) {
if (data && data.items && data.items.length > 0) {
return State.update({
Expand All @@ -68,8 +68,8 @@ function finishDeploy() {
}
function commitOrRollBack(state) {

return function () {
return State.getBranchesInStates(stateMap.committable)
return function (build) {
return State.getBranchesInStates(build.repo, stateMap.committable)
.then(function (data) {
if (data && data.items && data.items.length > 0) {
return State.update({
Expand All @@ -83,8 +83,8 @@ function commitOrRollBack(state) {
};
}

function failDeploy() {
return State.getBranchesInStates(stateMap.failable)
function failDeploy(build) {
return State.getBranchesInStates(build.repo, stateMap.failable)
.then(function (data) {
if (data && data.items && data.items.length > 0) {
return State.update({
Expand All @@ -97,8 +97,8 @@ function failDeploy() {
});
}

function cancelDeploy() {
return State.getBranchesInStates(stateMap.cancelable)
function cancelDeploy(build) {
return State.getBranchesInStates(build.repo, stateMap.cancelable)
.then(function (data) {
if (data && data.items && data.items.length > 0) {
return State.update({
Expand Down
6 changes: 3 additions & 3 deletions src/models/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ var _ = require('lodash'),
});


function getBranchesInStates(states) {
function getBranchesInStates(repo, states) {

return table.scan()
.where('state').in(states)
return table.query(repo)
.filter('state').in(states)
.execAsync()
.then(function (data) {
return {
Expand Down
18 changes: 9 additions & 9 deletions test/mgr.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ describe.skip('Test Mgr', function () {
state: 'requested'
}, build))
.then(function () {
return mgr.start();
return mgr.start(build);
})
.then(function () {
return State.table.getAsync({
Expand All @@ -113,7 +113,7 @@ describe.skip('Test Mgr', function () {
state: 'rolledBack'
}, build))
.then(function () {
return mgr.start();
return mgr.start(build);
})
.catch(function (err) {
err.message.should.equal('There is already requested build. Need to Wait...');
Expand All @@ -139,7 +139,7 @@ describe.skip('Test Mgr', function () {
State.create(_.assign({}, builds[1]))
])
.then(function () {
return mgr.finish();
return mgr.finish(builds[0]);
})
.then(function () {
return Promise.all([
Expand Down Expand Up @@ -178,7 +178,7 @@ describe.skip('Test Mgr', function () {
State.create(_.assign({}, builds[1]))
])
.then(function () {
return mgr.finish()
return mgr.finish(builds[0])
.catch(function (err) {
err.message.should.equal('There is no started build yet');

Expand Down Expand Up @@ -220,7 +220,7 @@ describe.skip('Test Mgr', function () {
State.create(_.assign({}, builds[1]))
])
.then(function () {
return mgr.fail();
return mgr.fail(builds[1]);
})
.then(function () {
return Promise.all([
Expand Down Expand Up @@ -258,7 +258,7 @@ describe.skip('Test Mgr', function () {
State.create(_.assign({}, builds[1]))
])
.then(function () {
return mgr.fail()
return mgr.fail(builds[1])
.catch(function (err) {
err.message.should.equal('There is no build started or finished');
});
Expand Down Expand Up @@ -299,7 +299,7 @@ describe.skip('Test Mgr', function () {
State.create(_.assign({}, builds[1]))
])
.then(function () {
return mgr.commit();
return mgr.commit(builds[1]);
})
.then(function () {
return Promise.all([
Expand Down Expand Up @@ -337,7 +337,7 @@ describe.skip('Test Mgr', function () {
State.create(_.assign({}, builds[1]))
])
.then(function () {
return mgr.rollBack();
return mgr.rollBack(builds[1]);
})
.then(function () {
return Promise.all([
Expand Down Expand Up @@ -375,7 +375,7 @@ describe.skip('Test Mgr', function () {
State.create(_.assign({}, builds[1]))
])
.then(function () {
return mgr.rollBack()
return mgr.rollBack(builds[1])
.catch(function(err){
err.message.should.equal('There is no build to be committed/rolled back yet');
})
Expand Down

0 comments on commit 99e76fb

Please sign in to comment.