Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Pundsack authored and jdx committed Jun 19, 2018
1 parent 635c30d commit 4020b84
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 42 deletions.
4 changes: 2 additions & 2 deletions packages/heroku-pipelines/commands/pipelines/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ module.exports = {
body: {pipeline: {id: pipeline.id}, stage: stage},
headers: { 'Accept': 'application/vnd.heroku+json; version=3.pipelines' }
}); // heroku.apps(app_id).pipline_couplings().create(body);
let app = yield cli.action(`Adding ${context.app} to ${pipeline.name} pipeline as ${stage}`, promise);
cli.hush(app);
let coupling = yield cli.action(`Adding ${context.app} to ${pipeline.name} pipeline as ${stage}`, promise);
cli.hush(coupling);
});
});
})
Expand Down
9 changes: 0 additions & 9 deletions packages/heroku-pipelines/commands/pipelines/info.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,5 @@ module.exports = {
}
// Pass in sort order for stages
cli.styledHash(stages, ["review", "development", "test", "qa", "staging", "production"]);

// let pipeline = context.args.pipeline || "example";
// cli.log(`=== ${pipeline}`);
// cli.log("Source type: github");
// cli.log("Source repo: heroku/example");
// cli.log("Staging: example-staging");
// cli.log("Production: example");
// cli.log(" example-admin");
// cli.log("Flow: example-staging —> example, example-admin");
})
};
29 changes: 12 additions & 17 deletions packages/heroku-pipelines/test/commands/pipelines/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,30 @@

let cli = require('heroku-cli-util');
let nock = require('nock');
let sinon = require('sinon');
let cmd = require('../../../commands/pipelines/create');

describe('pipelines:create', function () {
beforeEach(function () {
this.cliDebug = sinon.stub(cli, 'debug');
cli.mockConsole();
});

afterEach(function () {
this.cliDebug.restore();
});

it('displays the app info and config vars', function () {
let self = this;
let app = {name: 'myapp', web_url: 'https://myapp.herokuapp.com/'};
let config = {FOO: 'bar'};
it('displays the pipeline name and app stage', function () {
let self = this;
let pipeline = {name: 'example', id: '0123'};
let pipeline_coupling = { id: '0123', stage: "production" };

nock('https://api.heroku.com')
.get('/apps/myapp')
.reply(200, app);
.post('/pipelines')
.reply(201, pipeline);

nock('https://api.heroku.com')
.get('/apps/myapp/config-vars')
.reply(200, config);
.post('/apps/example/pipeline-couplings')
.reply(201, pipeline_coupling);

return cmd.run({app: 'myapp'})
return cmd.run({app: 'example', args: {name: 'example'}, flags: {stage: 'production'}})
.then(function () {
self.cliDebug.should.have.been.calledWith(app);
self.cliDebug.should.have.been.calledWith(config);
cli.stdout.should.contain('example');
cli.stdout.should.contain('production');
});
});
});
24 changes: 10 additions & 14 deletions packages/heroku-pipelines/test/commands/pipelines/info.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,31 @@
'use strict';

let cli = require('heroku-cli-util');
let cmd = require('../../../commands/pipelines/info');
let cli = require('heroku-cli-util');
let nock = require('nock');
let cmd = require('../../../commands/pipelines/info');

describe('pipelines:info', function () {
beforeEach(function () {
cli.mockConsole();
});

it('displays the app info and config vars', function () {
it('displays the pipeline info and apps', function () {
let self = this;
let pipeline = {name: 'example', source_type: 'github', source_repo: 'heroku/example'};
let apps = [{name: 'example-staging', stage: 'staging'}, {name: 'example', stage: 'production'}, {name: 'example-admin', stage: 'production'}];
let pipeline = {name: 'example', id: '0123'};
let apps = [{name: 'example-staging', coupling: {stage: 'staging'}, pipeline: pipeline}, {name: 'example', coupling: {stage: 'production'}, pipeline: pipeline}, {name: 'example-admin', coupling: {stage: 'production'}, pipeline: pipeline}];

nock('https://api.heroku.com')
.get('/pipelines/example')
.reply(200, pipeline);

nock('https://api.heroku.com')
.get('/pipelines/example/apps')
.get('/pipelines/0123/apps')
.reply(200, apps);

return cmd.run({app: 'example'})
return cmd.run({args: {pipeline: 'example'}})
.then(function () {
self.cliDebug.should.have.been.calledWith(pipeline);
self.cliDebug.should.have.been.calledWith(apps);
cli.stdout.should.contain('Staging:');
cli.stdout.should.contain('example-staging');
});
});

it('says "example" when the user is "example"', function () {
cmd.run({args: {pipeline: 'example'}});
cli.stdout.should.containe('example');
});
});

0 comments on commit 4020b84

Please sign in to comment.