Skip to content

Commit

Permalink
Rename push action to swagger
Browse files Browse the repository at this point in the history
  • Loading branch information
Dom Harrington committed Mar 8, 2018
1 parent 2ff1828 commit f6b17a5
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion lib/push.js → lib/swagger.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var path = require('path');

exports.swagger = true;
exports.login = true;
exports.desc = "Get a public URL for your API";
exports.desc = 'Upload your swagger file to ReadMe';
exports.category = "services";

exports.run = function(config, info, cb) {
Expand All @@ -26,6 +26,7 @@ exports.run = function(config, info, cb) {
console.log(data);
console.log("Success! ".green);
} else {
console.log(data);
console.error("There was an error uploading!".red);
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"author": "ReadMe <support@readme.io> (http://readme.io)",
"name": "rdme",
"description": "Upload your Swagger file to ReadMe",
"description": "ReadMe's API CLI",
"bin": {
"rdme": "index.js"
},
Expand Down
8 changes: 4 additions & 4 deletions test/push.test.js → test/swagger.test.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
const nock = require('nock');

const utils = require('../utils');
const push = require('../lib/push');
const swagger = require('../lib/swagger');

const config = utils.config('test');
const apiKey = 'Xmw4bGctRVIQz7R7dQXqH9nQe5d0SPQs'

describe('push action', () => {
describe('swagger action', () => {
after(() => nock.cleanAll());

it('should POST to the swagger api if no id provided', (done) => {
const mock = nock(config.host.url).post('/api/v1/swagger', (body) => {
return body.match('form-data; name=\"swagger\"');
}).basicAuth({ user: apiKey }).reply(201);

push.run(config, { args: ['./test/fixtures/json/swagger.json'], opts: { token: apiKey } }, (err) => {
swagger.run(config, { args: ['./test/fixtures/json/swagger.json'], opts: { token: apiKey } }, (err) => {
if (err) return done(err);
mock.done();

Expand All @@ -28,7 +28,7 @@ describe('push action', () => {
return body.match('form-data; name=\"swagger\"');
}).basicAuth({ user: apiKey }).reply(201);

push.run(config, { args: ['./test/fixtures/json/swagger.json'], opts: { token: `${apiKey}-${id}` } }, (err) => {
swagger.run(config, { args: ['./test/fixtures/json/swagger.json'], opts: { token: `${apiKey}-${id}` } }, (err) => {
if (err) return done(err);
mock.done();

Expand Down
File renamed without changes.

0 comments on commit f6b17a5

Please sign in to comment.