Skip to content

Commit

Permalink
gitflow-feature-stash: RunMochaHostBranches
Browse files Browse the repository at this point in the history
genoatt and runmocha batch changed to support multi-host testing.
  • Loading branch information
SimonGoring committed Mar 22, 2023
1 parent 221a944 commit a3a5da8
Show file tree
Hide file tree
Showing 80 changed files with 1,614 additions and 1,547 deletions.
2 changes: 1 addition & 1 deletion genoatt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ remote=localhost:3005
t)
test=1
;;
d)
d)
remote=api-dev.neotomadb.org
;;
p)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "1.4.0",
"private": true,
"scripts": {
"start": "node ./bin/www",
"start": "node --inspect ./bin/www",
"test": "node ./node_modules/mocha/bin/mocha --config=test/.mocharc.yml --reporter-options reportDir=public,reportFilename=tests"
},
"pre-commit": "test",
Expand Down
2 changes: 1 addition & 1 deletion public/tests.html

Large diffs are not rendered by default.

2,850 changes: 1,394 additions & 1,456 deletions public/tests.json

Large diffs are not rendered by default.

50 changes: 49 additions & 1 deletion runmochabatch.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,51 @@
#!/bin/bash
show_help() {
cat <<HELP
Usage: bash runmochabatch.sh [-hdp]
This is intended to be used with the genoatts.sh bash script to assist with testing the API on local and remote servers.
This bash script uses Mocha (and associated packages) to run tests against the API.
Options:
[none] run Mocha tests locally and build the reporter in ./public/tests.html
-h display this help and exit
-d run the tests against the remove development server at api-dev.neotomadb.org
-p run the tests against the remove production server at api.neotomadb.org
HELP
}

run_mocha() {
mocha --config=test/.mocharc.yml --reporter-options reportDir=public,reportFilename=tests
}

OPTIND=1
# Resetting OPTIND is necessary if getopts was used previously in the script.
# It is a good idea to make OPTIND local if you process options in a function.

test=0

while getopts "hdp" opt; do
case $opt in
h)
show_help
exit 0
;;
d)
export APIPATH='https://api-dev.neotomadb.org/'
;;
p)
export APIPATH='https://api.neotomadb.org/'
;;
*)
export APIPATH='http://localhost:3005/'
;;
esac
done

run_mocha

shift "$((OPTIND-1))" # Discard the options and sentinel --


mocha --config=test/.mocharc.yml --reporter-options reportDir=public,reportFilename=tests
1 change: 1 addition & 0 deletions test/.mocharc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ color: true
full-trace: true
ui: 'bdd'
reporter: 'mochawesome'
retries: 3
9 changes: 8 additions & 1 deletion test/chronologies.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@ var supertest = require('supertest');
const dotenv = require('dotenv');
dotenv.config();

var api = supertest('http://localhost:' + process.env.APIPORT + '/');
if (typeof process.env.APIPATH === 'undefined') {
var testroute = 'http://localhost:' + process.env.APIPORT + '/'
} else {
testroute = process.env.APIPATH
}

var api = supertest(testroute);

// *************************************************
// Chronology Data:
//
Expand Down
10 changes: 9 additions & 1 deletion test/contacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@ var supertest = require('supertest');
const dotenv = require('dotenv');
dotenv.config();

var api = supertest('http://localhost:' + process.env.APIPORT + '/');
if (typeof process.env.APIPATH === 'undefined') {
var testroute = 'http://localhost:' + process.env.APIPORT + '/'
} else {
testroute = process.env.APIPATH
}

console.log(testroute)

var api = supertest(testroute);

// *************************************************
// Contact Data:
Expand Down
8 changes: 7 additions & 1 deletion test/datasets.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ var supertest = require('supertest');
const dotenv = require('dotenv');
dotenv.config();

var api = supertest('http://localhost:' + process.env.APIPORT + '/');
if (typeof process.env.APIPATH === 'undefined') {
var testroute = 'http://localhost:' + process.env.APIPORT + '/'
} else {
testroute = process.env.APIPATH
}

var api = supertest(testroute);

// *************************************************
// Datasets:
Expand Down
10 changes: 9 additions & 1 deletion test/explorerCalls.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@ var expect = chakram.expect;
const dotenv = require('dotenv');
dotenv.config();

let appServicesLocation = 'http://localhost:' + process.env.APIPORT + '/v1.5/apps';
if (typeof process.env.APIPATH === 'undefined') {
var testroute = 'http://localhost:' + process.env.APIPORT + '/'
} else {
testroute = process.env.APIPATH
}

let appServicesLocation = testroute + 'v1.5/apps';

// let appServicesLocation = 'http://localhost:' + process.env.APIPORT + '/v1.5/apps';

describe('Tests for Explorer App Services', function () {
this.timeout(12000);
Expand Down
8 changes: 7 additions & 1 deletion test/geopolitical.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ var supertest = require('supertest');
const dotenv = require('dotenv');
dotenv.config();

var api = supertest('http://localhost:' + process.env.APIPORT + '/');
if (typeof process.env.APIPATH === 'undefined') {
var testroute = 'http://localhost:' + process.env.APIPORT + '/'
} else {
testroute = process.env.APIPATH
}

var api = supertest(testroute);

// *************************************************
// Geopolitical Units:
Expand Down
8 changes: 7 additions & 1 deletion test/neotoma_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ var supertest = require('supertest');
const dotenv = require('dotenv');
dotenv.config();

var api = supertest('http://localhost:' + process.env.APIPORT + '/');
if (typeof process.env.APIPATH === 'undefined') {
var testroute = 'http://localhost:' + process.env.APIPORT + '/'
} else {
testroute = process.env.APIPATH
}

var api = supertest(testroute);

// *************************************************
// Main controllers:
Expand Down
8 changes: 7 additions & 1 deletion test/occurrence.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ var supertest = require('supertest');
const dotenv = require('dotenv');
dotenv.config();

var api = supertest('http://localhost:' + process.env.APIPORT + '/');
if (typeof process.env.APIPATH === 'undefined') {
var testroute = 'http://localhost:' + process.env.APIPORT + '/'
} else {
testroute = process.env.APIPATH
}

var api = supertest(testroute);

// *************************************************
// Occurrence Data:
Expand Down
9 changes: 8 additions & 1 deletion test/publications.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ var supertest = require('supertest');
const dotenv = require('dotenv');
dotenv.config();

var api = supertest('http://localhost:' + process.env.APIPORT + '/');
if (typeof process.env.APIPATH === 'undefined') {
var testroute = 'http://localhost:' + process.env.APIPORT + '/'
} else {
testroute = process.env.APIPATH
}

var api = supertest(testroute);

// *************************************************
// Site Data:
//
Expand Down
8 changes: 7 additions & 1 deletion test/responsevalidate.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ const YAML = require('yamljs');
const dotenv = require('dotenv');
dotenv.config();

const api = supertest('http://localhost:' + process.env.APIPORT + '/');
if (typeof process.env.APIPATH === 'undefined') {
var testroute = 'http://localhost:' + process.env.APIPORT + '/'
} else {
testroute = process.env.APIPATH
}

var api = supertest(testroute);

const fullPath = path.join(process.cwd(), 'swagger.yaml');
const apidoc = YAML.load(fullPath)
Expand Down
9 changes: 8 additions & 1 deletion test/sites.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ var supertest = require('supertest');
const dotenv = require('dotenv');
dotenv.config();

var api = supertest('http://localhost:' + process.env.APIPORT + '/');
if (typeof process.env.APIPATH === 'undefined') {
var testroute = 'http://localhost:' + process.env.APIPORT + '/'
} else {
testroute = process.env.APIPATH
}

var api = supertest(testroute);

// *************************************************
// Site Data:
//
Expand Down
9 changes: 8 additions & 1 deletion test/spatial.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ var supertest = require('supertest');
const dotenv = require('dotenv');
dotenv.config();

var api = supertest('http://localhost:' + process.env.APIPORT + '/');
if (typeof process.env.APIPATH === 'undefined') {
var testroute = 'http://localhost:' + process.env.APIPORT + '/'
} else {
testroute = process.env.APIPATH
}

var api = supertest(testroute);

// *************************************************
// Occurrence Data:
//
Expand Down
8 changes: 7 additions & 1 deletion test/taxa.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ var supertest = require('supertest');
const dotenv = require('dotenv');
dotenv.config();

var api = supertest('http://localhost:' + process.env.APIPORT + '/');
if (typeof process.env.APIPATH === 'undefined') {
var testroute = 'http://localhost:' + process.env.APIPORT + '/'
} else {
testroute = process.env.APIPATH
}

var api = supertest(testroute);

// *************************************************
// Taxon Data:
Expand Down
2 changes: 1 addition & 1 deletion test/v1.5-apps-DatasetTypes-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var expect = chakram.expect;
describe('tests for /v1.5/apps/DatasetTypes', function () {
describe('tests for get', function () {
it('should respond 200 for "Returns the set of dataset types supported by Neotoma."', function () {
var response = request('get', 'http://api.neotomadb.org/v1.5/apps/DatasetTypes', {
var response = request('get', 'http://localhost:3005/v1.5/apps/DatasetTypes', {
'time': true
});

Expand Down
2 changes: 1 addition & 1 deletion test/v1.5-apps-TaxaInDatasets-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var expect = chakram.expect;
describe('tests for /v1.5/apps/TaxaInDatasets', function () {
describe('tests for get', function () {
it('should respond 200 for "An array of taxon identities with associated dataset IDs."', function () {
var response = request('get', 'http://api.neotomadb.org/v1.5/apps/TaxaInDatasets', {
var response = request('get', 'http://localhost:3005/v1.5/apps/TaxaInDatasets', {
'time': true
});

Expand Down
2 changes: 1 addition & 1 deletion test/v1.5-apps-collectionTypes-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var expect = chakram.expect;
describe('tests for /v1.5/apps/collectionTypes', function () {
describe('tests for get', function () {
it('should respond 200 for "Returns the set of collectiontypes recorded in Neotoma."', function () {
var response = request('get', 'http://api.neotomadb.org/v1.5/apps/collectionTypes', {
var response = request('get', 'http://localhost:3005/v1.5/apps/collectionTypes', {
'time': true
});

Expand Down
2 changes: 1 addition & 1 deletion test/v1.5-data-contacts-{contactid}-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var expect = chakram.expect;
describe('tests for /v1.5/data/contacts/{contactid}', function () {
describe('tests for get', function () {
it('should respond 200 for "Contact"', function () {
var response = request('get', 'http://api.neotomadb.org/v1.5/data/contacts/-82810541', {
var response = request('get', 'http://localhost:3005/v1.5/data/contacts/500', {
'time': true
});

Expand Down
2 changes: 1 addition & 1 deletion test/v1.5-data-datasets-{datasetid}-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var expect = chakram.expect;
describe('tests for /v1.5/data/datasets/{datasetid}', function () {
describe('tests for get', function () {
it('should respond 200 for "An array of datasets."', function () {
var response = request('get', 'http://api.neotomadb.org/v1.5/data/datasets/500', {
var response = request('get', 'http://localhost:3005/v1.5/data/datasets/500', {
'time': true
});

Expand Down
2 changes: 1 addition & 1 deletion test/v1.5-data-downloads-{datasetid}-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var expect = chakram.expect;
describe('tests for /v1.5/data/downloads/{datasetid}', function () {
describe('tests for get', function () {
it('should respond 200 for "Returned download object."', function () {
var response = request('get', 'http://api.neotomadb.org/v1.5/data/downloads/500', {
var response = request('get', 'http://localhost:3005/v1.5/data/downloads/500', {
'time': true
});

Expand Down
4 changes: 2 additions & 2 deletions test/v1.5-data-geopoliticalunits-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ var expect = chakram.expect;
describe('tests for /v1.5/data/geopoliticalunits', function () {
describe('tests for get', function () {
it('should respond 200 for "An array of geopolitical units."', function () {
var response = request('get', 'http://api.neotomadb.org/v1.5/data/geopoliticalunits', {
'qs': { 'gpid': 756, 'gpname': 'Canada', 'rank': 3, 'lower': false },
var response = request('get', 'http://localhost:3005/v1.5/data/geopoliticalunits', {
'qs': { 'gpid': 756, 'gpname': 'Canada', 'rank': 1, 'lower': true },
'time': true
});

Expand Down
2 changes: 1 addition & 1 deletion test/v1.5-data-geopoliticalunits-{gpid}-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var expect = chakram.expect;
describe('tests for /v1.5/data/geopoliticalunits/{gpid}', function () {
describe('tests for get', function () {
it('should respond 200 for "An array of geopolitical units."', function () {
var response = request('get', 'http://api.neotomadb.org/v1.5/data/geopoliticalunits/614', {
var response = request('get', 'http://localhost:3005/v1.5/data/geopoliticalunits/9482', {
'time': true
});

Expand Down
2 changes: 1 addition & 1 deletion test/v1.5-data-occurrence-{occurrenceid}-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var expect = chakram.expect;
describe('tests for /v1.5/data/occurrence/{occurrenceid}', function () {
describe('tests for get', function () {
it('should respond 200 for "A single occurrence object."', function () {
var response = request('get', 'http://api.neotomadb.org/v1.5/data/occurrence/500', {
var response = request('get', 'http://localhost:3005/v1.5/data/occurrence/500', {
'time': true
});

Expand Down
2 changes: 1 addition & 1 deletion test/v1.5-data-sites-{siteid}-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var expect = chakram.expect;
describe('tests for /v1.5/data/sites/{siteid}', function () {
describe('tests for get', function () {
it('should respond 200 for "An array of site elements."', function () {
var response = request('get', 'http://api.neotomadb.org/v1.5/data/sites/4705', {
var response = request('get', 'http://localhost:3005/v1.5/data/sites/500', {
'time': true
});

Expand Down
2 changes: 1 addition & 1 deletion test/v1.5-dbtables-{table}-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var expect = chakram.expect;
describe('tests for /v1.5/dbtables/{table}', function () {
describe('tests for get', function () {
it('should respond 200 for "Returned table."', function () {
var response = request('get', 'http://api.neotomadb.org/v1.5/dbtables/geochrontypes', {
var response = request('get', 'http://localhost:3005/v1.5/dbtables/geochrontypes', {
'time': true
});

Expand Down
2 changes: 1 addition & 1 deletion test/v2.0-apps-authorpis-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var expect = chakram.expect;
describe('tests for /v2.0/apps/authorpis', function () {
describe('tests for get', function () {
it('should respond 200 for "A table of Neotoma collection types."', function () {
var response = request('get', 'http://api.neotomadb.org/v2.0/apps/authorpis', {
var response = request('get', 'http://localhost:3005/v2.0/apps/authorpis', {
'time': true
});

Expand Down
2 changes: 1 addition & 1 deletion test/v2.0-apps-collectiontypes-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var expect = chakram.expect;
describe('tests for /v2.0/apps/collectiontypes', function () {
describe('tests for get', function () {
it('should respond 200 for "A table of Neotoma collection types."', function () {
var response = request('get', 'http://api.neotomadb.org/v2.0/apps/collectiontypes', {
var response = request('get', 'http://localhost:3005/v2.0/apps/collectiontypes', {
'time': true
});

Expand Down
2 changes: 1 addition & 1 deletion test/v2.0-apps-datasettypes-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var expect = chakram.expect;
describe('tests for /v2.0/apps/datasettypes', function () {
describe('tests for get', function () {
it('should respond 200 for "A table of Neotoma collection types."', function () {
var response = request('get', 'http://api.neotomadb.org/v2.0/apps/datasettypes', {
var response = request('get', 'http://localhost:3005/v2.0/apps/datasettypes', {
'time': true
});

Expand Down
Loading

0 comments on commit a3a5da8

Please sign in to comment.