-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 138f926
Showing
26 changed files
with
608 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
insert_final_newline = true | ||
|
||
[*.{js,json}] | ||
charset = utf-8 | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[{package.json,.travis.yml}] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[*.go] | ||
charset = utf-8 | ||
indent_style = tab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
.idea | ||
.DS_Store | ||
|
||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directory | ||
# https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git | ||
node_modules | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
*~ | ||
\#*\# | ||
.\#* | ||
|
||
# Ignore dirs | ||
/build/ | ||
/deploy/ | ||
/logs/ | ||
/reports/ | ||
/.gauge/ | ||
|
||
# Screenshot | ||
screenshot-test.png |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"disallowMixedSpacesAndTabs": true, | ||
"disallowSpaceBeforeComma": true, | ||
"requireCapitalizedConstructors": true, | ||
"requireSemicolons": true, | ||
"requireSpacesInForStatement": true, | ||
"validateIndentation": 2, | ||
"validateLineBreaks": "LF", | ||
"validateQuoteMarks": { "mark": "\"", "escape": true } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{ | ||
"bitwise": false, | ||
"camelcase": false, | ||
"curly": true, | ||
"eqeqeq": false, | ||
"es3": false, | ||
"forin": false, | ||
"freeze": true, | ||
"immed": true, | ||
"latedef": true, | ||
"newcap": true, | ||
"noarg": true, | ||
"noempty": true, | ||
"nonew": false, | ||
"plusplus": false, | ||
"quotmark": "double", | ||
"undef": true, | ||
"unused": true, | ||
"trailing": true, | ||
"asi": false, | ||
"boss": true, | ||
"debug": false, | ||
"eqnull": true, | ||
"evil": false, | ||
"expr": true, | ||
"funcscope": false, | ||
"globalstrict": false, | ||
"iterator": false, | ||
"lastsemic": false, | ||
"laxbreak": false, | ||
"laxcomma": false, | ||
"loopfunc": false, | ||
"multistr": false, | ||
"maxcomplexity": 10, | ||
"mocha": true, | ||
"notypeof": false, | ||
"predef" : [ "gaugejs", "gauge"], | ||
"proto": false, | ||
"scripturl": false, | ||
"smarttabs": false, | ||
"shadow": false, | ||
"sub": false, | ||
"supernew": false, | ||
"browser": false, | ||
"devel": true, | ||
"node": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Demo of testing Swagger Web API with Gauge JS | ||
|
||
This demo tests a dummy NodeJS-based Web API written with Swagger with [Gauge][_gauge], using the [JavaScript][_gaugejs] language runner. | ||
|
||
## Setting up | ||
|
||
* Install [Gauge][_gauge]. | ||
* Install [NodeJS][_node]. | ||
* Install Swagger: `$ sudo npm install -g swagger` | ||
* Install [Gauge JS][_gaugejs] runner: `$ gauge --install js` | ||
* In the project root directory, run: `$ npm install` | ||
|
||
## Running Gauge tests | ||
|
||
* `$ npm start`: Start the Swagger API server. | ||
* `$ npm test`: While the server is running, run Gauge tests (in another terminal). | ||
|
||
## Project layout | ||
|
||
- API Server: [`./server/`](server) | ||
- Gauge specifications: [`./specs/`](specs) | ||
- Test implementations: [`./tests/`](tests) | ||
|
||
[_gauge]: http://getgauge.io | ||
[_gaugejs]: https://github.com/getgauge-contrib/gauge-js | ||
[_node]: https://nodejs.org |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# default.properties | ||
# properties set here will be available to the test execution as environment variables | ||
|
||
# sample_key = sample_value | ||
|
||
#The path to the gauge reports directory. Should be either relative to the project directory or an absolute path | ||
gauge_reports_dir = reports | ||
|
||
#Set as false if gauge reports should not be overwritten on each execution. A new time-stamped directory will be created on each execution. | ||
overwrite_reports = true | ||
|
||
# Set to false to disable screenshots on failure in reports. | ||
screenshot_on_failure = false | ||
|
||
# The path to the gauge logs directory. Should be either relative to the project directory or an absolute path | ||
logs_directory = logs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#js.properties | ||
#settings related to gauge-js. | ||
|
||
test_timeout = 10000 | ||
|
||
# Change this to true to enable debugging support | ||
DEBUG = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
API_BASE = http://localhost:10010/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"Language": "js", | ||
"Plugins": [ | ||
"html-report" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"name": "gauge-js-swagger-demo", | ||
"version": "0.1.0", | ||
"description": "Demo of testing Swagger API with Gauge in JavaScript", | ||
"scripts": { | ||
"setup": "cd server && npm install", | ||
"start": "npm run setup && swagger project start server", | ||
"test": "gauge specs/" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/getgauge/gauge-js-swagger-demo.git" | ||
}, | ||
"keywords": [ | ||
"getgauge", | ||
"swagger", | ||
"api", | ||
"testing", | ||
"demo" | ||
], | ||
"author": "Kaustav Das Modak <[email protected]>", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/getgauge/gauge-js-swagger-demo/issues" | ||
}, | ||
"homepage": "https://github.com/getgauge/gauge-js-swagger-demo#readme", | ||
"dependencies": { | ||
"request": "^2.72.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# IDE files | ||
.idea | ||
|
||
# Logs | ||
logs | ||
*.log | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directory | ||
# Commenting this out is preferred by some people, see | ||
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git | ||
node_modules | ||
|
||
# Users Environment Variables | ||
.lock-wscript | ||
|
||
# Runtime configuration for swagger app | ||
config/runtime.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# API Server for Gauge Swagger demo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Place your controllers in this directory. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// GET messages | ||
var get = function (req, res) { | ||
console.log("Sending message list", db.msgs); | ||
res.json(db.msgs); | ||
}; | ||
|
||
// POST messages | ||
var post = function (req, res) { | ||
var msg = req.swagger.params.msg.value || ""; | ||
db.msgs.push(msg); | ||
console.log("Inserting message", msg); | ||
res.json("Ok"); | ||
}; | ||
|
||
// DELETE messages | ||
var clear = function (req, res) { | ||
console.log("Clearing messages"); | ||
db.msgs = []; | ||
res.json("Ok"); | ||
}; | ||
|
||
module.exports = { get: get, post: post, delete: clear }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Place helper files in this directory. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Place controllers for mock mode in this directory. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
swagger: "2.0" | ||
info: | ||
version: "0.0.1" | ||
title: Gauge Swagger Demo Server | ||
# during dev, should point to your local machine | ||
host: localhost:10010 | ||
# basePath prefixes all resource paths | ||
basePath: / | ||
# | ||
schemes: | ||
# tip: remove http to make production-grade | ||
- http | ||
- https | ||
# format of bodies a client can send (Content-Type) | ||
consumes: | ||
- application/json | ||
# format of the responses to the client (Accepts) | ||
produces: | ||
- application/json | ||
|
||
paths: | ||
/messages: | ||
x-swagger-router-controller: messages | ||
get: | ||
description: Get a list of messages sent so far | ||
produces: | ||
- application/json | ||
responses: | ||
'200': | ||
$ref: '#/responses/MessageList' | ||
post: | ||
description: Write a new message | ||
consumes: | ||
- application/json | ||
produces: | ||
- application/json | ||
parameters: | ||
- name: msg | ||
in: body | ||
required: true | ||
schema: | ||
type: string | ||
responses: | ||
'200': | ||
$ref: '#/responses/Success' | ||
delete: | ||
description: Clear existing messages | ||
produces: | ||
- application/json | ||
responses: | ||
'200': | ||
$ref: '#/responses/Success' | ||
|
||
definitions: | ||
Msg: | ||
title: Message | ||
description: A single message | ||
type: string | ||
|
||
responses: | ||
Success: | ||
description: Response sent on a success. | ||
schema: | ||
type: string | ||
MessageList: | ||
description: Response containing list of messages. | ||
schema: | ||
description: Message list | ||
type: array | ||
items: | ||
$ref: '#/definitions/Msg' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
'use strict'; | ||
|
||
var SwaggerExpress = require('swagger-express-mw'); | ||
var app = require('express')(); | ||
module.exports = app; // for testing | ||
|
||
var config = { | ||
appRoot: __dirname // required config | ||
}; | ||
|
||
global.db = { | ||
msgs: [] | ||
}; | ||
|
||
SwaggerExpress.create(config, function(err, swaggerExpress) { | ||
if (err) { throw err; } | ||
|
||
// install middleware | ||
swaggerExpress.register(app); | ||
|
||
var port = process.env.PORT || 10010; | ||
app.listen(port); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Place configuration files in this directory. |
Oops, something went wrong.