Comparing version 0.3.7 to 0.3.8
@@ -7,3 +7,3 @@ // Bluecat client command line tool | ||
var Inquirer = require('inquirer'); | ||
var Exec = require('child_process').exec; | ||
var Exec = require('child_process').execSync; | ||
var argv = require('yargs') | ||
@@ -47,3 +47,3 @@ .usage('Usage: $0 <config|api>') | ||
}; | ||
Fs.appendFileSync(Path.join(dir, 'api.json'), JSON.stringify(content, null, 2) + ',\n'); | ||
Fs.appendFileSync(Path.join(dir, 'api.json'), JSON.stringify(content, null, 2)); | ||
@@ -54,6 +54,6 @@ content = { | ||
server: { | ||
host: "http://httpbin.org/", | ||
host: "httpbin.org", | ||
} | ||
}; | ||
Fs.appendFileSync(Path.join(dir, 'default.json'), JSON.stringify(content, null, 2) + ',\n'); | ||
Fs.appendFileSync(Path.join(dir, 'default.json'), JSON.stringify(content, null, 2)); | ||
@@ -69,3 +69,3 @@ // setting up test dir | ||
var api = Bluecat.Api('pangaea'); | ||
var api = Bluecat.Api('${answers.project_name}'); | ||
@@ -76,4 +76,48 @@ service = new Bluecat.ServiceSync(api, Config.server.host); | ||
`; | ||
Fs.appendFileSync(Path.join(dir, 'test.js'), JSON.stringify(content, null, 2) + ',\n'); | ||
Fs.appendFileSync(Path.join(dir, 'test.js'), testContent); | ||
Fs.mkdirSync(Path.join(dir, answers.project_name)); | ||
testContent = ` | ||
// Sample test suite utilizing Bluecat | ||
var expect = require('chai').expect; | ||
var test = require('../../test/test.js'); | ||
describe('Sample test suite', function() { | ||
before(function() { | ||
service = test.${answers.project_name}; | ||
}); | ||
it('sample test to get endpoint [C001]', function(done) { | ||
service.run(function() { | ||
var r = service.get.GET({}); | ||
expect(r.data.statusCode).to.equal(200); | ||
expect(r.data.body).is.a('object'); | ||
expect(r.data.body.url).to.equal('http://httpbin.org/get'); | ||
done(); | ||
}); | ||
}); | ||
it('sample test to post endpoint [C002]', function(done) { | ||
service.run(function() { | ||
var payload = { | ||
sample: { | ||
addressLineOne: '755 abc Ave', | ||
city: 'Albany' | ||
} | ||
}; | ||
var r = service.post.POST({ | ||
body: payload | ||
}); | ||
expect(r.data.statusCode).to.equal(200); | ||
expect(r.data.body).is.a('object'); | ||
expect(r.data.body.json.sample.city).to.equal('Albany'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
` | ||
Fs.appendFileSync(Path.join(dir, answers.project_name, 'sample.js'), testContent); | ||
// setting up root dir | ||
@@ -86,6 +130,11 @@ var content = { | ||
}; | ||
Fs.appendFileSync(Path.join(process.cwd(), 'package.json'), JSON.stringify(conntent, null, 2) + ',\n'); | ||
Fs.appendFileSync(Path.join(process.cwd(), 'package.json'), JSON.stringify(content, null, 2)); | ||
console.log('Installing npm package...'); | ||
var output = Exec('npm install bluecat chai config mocha mocha-espresso mocha-multi --save'); | ||
output.on('error', function(err) { | ||
console.log('Error when running npm install: ' + err); | ||
exit(1); | ||
}); | ||
}); | ||
} | ||
exports.ServiceSync = require('./service.gen.sync'); | ||
exports.ServiceAsync = require('./service.gen.async'); | ||
exports.Api = require('./service.api'); | ||
exports.version = '0.3.7'; | ||
exports.version = '0.3.8'; |
{ | ||
"name": "bluecat", | ||
"version": "0.3.7", | ||
"version": "0.3.8", | ||
"author": "ccy <ccy.chenchaoyi@gmail.com>", | ||
@@ -5,0 +5,0 @@ "description": "Generic REST API Test Framework", |
29522
675