Skip to content

Commit

Permalink
Merge pull request #7 from TryxAPI/fix-document-js
Browse files Browse the repository at this point in the history
Update selecting directory.  Cleanup / refactor document tests.
  • Loading branch information
toaster33 committed May 11, 2015
2 parents 91f06ea + a24ffd6 commit 8814bcf
Show file tree
Hide file tree
Showing 5 changed files with 644 additions and 459 deletions.
8 changes: 5 additions & 3 deletions bin/lrs-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
(function (process, require, program, exit, packageJson, Q, Joi, fs, path, Mocha) {
'use strict';

var DIRECTORY = 'v1_0_2';

program
.version(packageJson.version)
.usage('[options]')
.option('-d, --directory [path]', 'test directory, default: test/v1_0_2')
.option('-d, --directory [path]', 'test directory, default: ' + DIRECTORY)
.option('-e, --endpoint <path>', 'the connection string')
.option('-a, --basicAuth <true/false>', 'enables basic authentication')
.option('-u, --authUser <username>', 'sets user name (required when basic authentication enabled)')
Expand All @@ -33,7 +35,7 @@

process.nextTick(function () {
var options = {
directory: program.directory || 'test/v1_0_2',
directory: program.directory || DIRECTORY,
endpoint: program.endpoint,
basicAuth: program.basicAuth,
authUser: program.authUser,
Expand All @@ -48,7 +50,7 @@
process.env.BASIC_AUTH_ENABLED = options.basicAuth;
process.env.BASIC_AUTH_USER = options.authUser;
process.env.BASIC_AUTH_PASSWORD = options.authPass;
var testDirectory = options.directory;
var testDirectory = 'test/' + options.directory;
fs.readdirSync(testDirectory).filter(function (file) {
return file.substr(-3) === '.js';
}).forEach(function (file) {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lrs-conformance-tests",
"version": "0.0.3",
"version": "1.1.1",
"description": "lrs-conformance-tests",
"main": "test.js",
"scripts": {
Expand Down Expand Up @@ -42,6 +42,6 @@
"super-request": "0.0.8",
"supertest": "^0.13.0",
"supertest-as-promised": "^1.0.0",
"valid-url": "^1.0.9"
"validator": "^3.39.0"
}
}
1 change: 1 addition & 0 deletions test/.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
LRS_ENDPOINT=http://asdf.elmnts-test.com:8001/lrs
XAPI_VERSION=1.0.1
DIRECTORY=v1_0_2
BASIC_AUTH_ENABLED=false
BASIC_AUTH_USER=username
BASIC_AUTH_PASSWORD=password
10 changes: 7 additions & 3 deletions test/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ if (!process.env.EB_NODE_COMMAND) {
/** Appears to use relative path */
var CONFIG_FOLDER_RELATIVE = './v1_0_2/configs';

/** Test directory */
var DIRECTORY = process.env.DIRECTORY;

/** Defines endpoint of the LRS you are testing. Currently assumes authentication is not required */
var LRS_ENDPOINT = process.env.LRS_ENDPOINT;

Expand Down Expand Up @@ -315,7 +318,9 @@ if (!process.env.EB_NODE_COMMAND) {
* @returns {string}
*/
buildActivity: function () {
return 'http://www.example.com/activityId/hashset';
return {
activityId: 'http://www.example.com/activityId/hashset'
};
},
/**
* Returns an example State params.
Expand Down Expand Up @@ -350,7 +355,6 @@ if (!process.env.EB_NODE_COMMAND) {
*/
buildAgentProfile: function () {
return {
activityId: 'http://www.example.com/activityId/hashset',
agent: {
"objectType": "Agent",
"account": {
Expand Down Expand Up @@ -396,7 +400,7 @@ if (!process.env.EB_NODE_COMMAND) {
* @returns {object} statement
*/
buildStatement: function () {
return clone(require('../data/statement_full.json'));
return module.exports.clone(require('./' + DIRECTORY + '/templates/statements/default.json'));
},
/**
* Deep clone object.
Expand Down
Loading

0 comments on commit 8814bcf

Please sign in to comment.