Fixup all the tests

This commit is contained in:
Nick O'Leary
2018-08-20 16:17:24 +01:00
parent 998bf92ad4
commit 38a1291c5b
113 changed files with 458 additions and 250 deletions

View File

@@ -17,7 +17,8 @@
var should = require("should");
var sinon = require("sinon");
var comms = require("../../../red/runtime-api/comms");
var NR_TEST_UTILS = require("nr-test-utils");
var comms = NR_TEST_UTILS.require("@node-red/runtime/lib/api/comms");
describe("runtime-api/comms", function() {
describe("listens for events", function() {

View File

@@ -14,6 +14,8 @@
* limitations under the License.
**/
var NR_TEST_UTILS = require("nr-test-utils");
describe("runtime-api/context", function() {
it.skip("NEEDS TESTS WRITING",function() {});
});

View File

@@ -18,7 +18,8 @@
var should = require("should");
var sinon = require("sinon");
var flows = require("../../../red/runtime-api/flows")
var NR_TEST_UTILS = require("nr-test-utils");
var flows = NR_TEST_UTILS.require("@node-red/runtime/lib/api/flows")
var mockLog = () => ({
log: sinon.stub(),

View File

@@ -17,18 +17,19 @@
var should = require("should");
var sinon = require("sinon");
var index = require("../../../red/runtime-api/index");
var NR_TEST_UTILS = require("nr-test-utils");
var index = NR_TEST_UTILS.require("@node-red/runtime/lib/api/index");
describe("runtime-api/index", function() {
before(function() {
["comms","flows","nodes","settings","library","projects"].forEach(n => {
sinon.stub(require(`../../../red/runtime-api/${n}`),"init",()=>{});
sinon.stub(NR_TEST_UTILS.require(`@node-red/runtime/lib/api/${n}`),"init",()=>{});
})
});
after(function() {
["comms","flows","nodes","settings","library","projects"].forEach(n => {
require(`../../../red/runtime-api/${n}`).init.restore()
NR_TEST_UTILS.require(`@node-red/runtime/lib/api/${n}`).init.restore()
})
})
it('isStarted', function(done) {

View File

@@ -18,7 +18,8 @@
var should = require("should");
var sinon = require("sinon");
var library = require("../../../red/runtime-api/library")
var NR_TEST_UTILS = require("nr-test-utils");
var library = NR_TEST_UTILS.require("@node-red/runtime/lib/api/library")
var mockLog = {
log: sinon.stub(),

View File

@@ -17,7 +17,8 @@
var should = require("should");
var sinon = require("sinon");
var nodes = require("../../../red/runtime-api/nodes")
var NR_TEST_UTILS = require("nr-test-utils");
var nodes = NR_TEST_UTILS.require("@node-red/runtime/lib/api/nodes")
var mockLog = () => ({
log: sinon.stub(),

View File

@@ -17,7 +17,8 @@
var should = require("should");
var sinon = require("sinon");
var projects = require("../../../red/runtime-api/projects")
var NR_TEST_UTILS = require("nr-test-utils");
var projects = NR_TEST_UTILS.require("@node-red/runtime/lib/api/projects")
var mockLog = () => ({
log: sinon.stub(),

View File

@@ -18,7 +18,8 @@
var should = require("should");
var sinon = require("sinon");
var settings = require("../../../red/runtime-api/settings")
var NR_TEST_UTILS = require("nr-test-utils");
var settings = NR_TEST_UTILS.require("@node-red/runtime/lib/api/settings")
var mockLog = () => ({
log: sinon.stub(),

View File

@@ -15,9 +15,11 @@
**/
var should = require("should");
var NR_TEST_UTILS = require("nr-test-utils");
describe("runtime/events", function() {
it('can be required without errors', function() {
require("../../../red/runtime/events");
NR_TEST_UTILS.require("@node-red/runtime/lib/events");
});
it.skip('more tests needed', function(){})
});

View File

@@ -17,13 +17,15 @@ var should = require("should");
var sinon = require("sinon");
var path = require("path");
var api = require("../../../red/api");
var runtime = require("../../../red/runtime");
var NR_TEST_UTILS = require("nr-test-utils");
var redNodes = require("../../../red/runtime/nodes");
var storage = require("../../../red/runtime/storage");
var settings = require("../../../red/runtime/settings");
var log = require("../../../red/util/log");
var api = NR_TEST_UTILS.require("@node-red/runtime/lib/api");
var runtime = NR_TEST_UTILS.require("@node-red/runtime");
var redNodes = NR_TEST_UTILS.require("@node-red/runtime/lib/nodes");
var storage = NR_TEST_UTILS.require("@node-red/runtime/lib/storage");
var settings = NR_TEST_UTILS.require("@node-red/runtime/lib/settings");
var log = NR_TEST_UTILS.require("@node-red/util").log;
describe("runtime", function() {
afterEach(function() {
@@ -33,7 +35,7 @@ describe("runtime", function() {
})
before(function() {
process.env.NODE_RED_HOME = path.resolve(path.join(__dirname,"..","..",".."))
process.env.NODE_RED_HOME = NR_TEST_UTILS.resolve("node-red");
});
after(function() {
delete process.env.NODE_RED_HOME;
@@ -75,7 +77,10 @@ describe("runtime", function() {
it("returns version", function() {
runtime.init({testSettings: true, httpAdminRoot:"/"},mockUtil());
/^\d+\.\d+\.\d+(-git)?$/.test(runtime.version()).should.be.true();
return runtime.version().then(version => {
/^\d+\.\d+\.\d+(-git)?$/.test(version).should.be.true();
});
})
});

View File

@@ -18,7 +18,8 @@ var should = require("should");
var sinon = require("sinon");
var fs = require("fs");
var library = require("../../../../red/runtime/library/index")
var NR_TEST_UTILS = require("nr-test-utils");
var library = NR_TEST_UTILS.require("@node-red/runtime/lib/library/index")
var mockLog = {
log: sinon.stub(),

View File

@@ -16,9 +16,10 @@
var should = require("should");
var sinon = require('sinon');
var RedNode = require("../../../../red/runtime/nodes/Node");
var Log = require("../../../../red/util/log");
var flows = require("../../../../red/runtime/nodes/flows");
var NR_TEST_UTILS = require("nr-test-utils");
var RedNode = NR_TEST_UTILS.require("@node-red/runtime/lib/nodes/Node");
var Log = NR_TEST_UTILS.require("@node-red/util").log;
var flows = NR_TEST_UTILS.require("@node-red/runtime/lib/nodes/flows");
describe('Node', function() {
describe('#constructor',function() {

View File

@@ -18,7 +18,8 @@ var should = require("should");
var sinon = require('sinon');
var path = require("path");
var fs = require('fs-extra');
var Context = require("../../../../../red/runtime/nodes/context/index");
var NR_TEST_UTILS = require("nr-test-utils");
var Context = NR_TEST_UTILS.require("@node-red/runtime/lib/nodes/context/index");
describe('context', function() {
describe('local memory',function() {

View File

@@ -17,7 +17,8 @@
var should = require('should');
var fs = require('fs-extra');
var path = require("path");
var LocalFileSystem = require('../../../../../red/runtime/nodes/context/localfilesystem');
var NR_TEST_UTILS = require("nr-test-utils");
var LocalFileSystem = NR_TEST_UTILS.require("@node-red/runtime/lib/nodes/context/localfilesystem");
var resourcesDir = path.resolve(path.join(__dirname,"..","resources","context"));

View File

@@ -15,7 +15,9 @@
**/
var should = require('should');
var Memory = require('../../../../../red/runtime/nodes/context/memory');
var NR_TEST_UTILS = require("nr-test-utils");
var Memory = NR_TEST_UTILS.require("@node-red/runtime/lib/nodes/context/memory");
describe('memory',function() {
var context;

View File

@@ -19,9 +19,10 @@ var sinon = require("sinon");
var when = require("when");
var util = require("util");
var index = require("../../../../red/runtime/nodes/index");
var credentials = require("../../../../red/runtime/nodes/credentials");
var log = require("../../../../red/util/log");
var NR_TEST_UTILS = require("nr-test-utils");
var index = NR_TEST_UTILS.require("@node-red/runtime/lib/nodes/index");
var credentials = NR_TEST_UTILS.require("@node-red/runtime/lib/nodes/credentials");
var log = NR_TEST_UTILS.require("@node-red/util").log;
describe('red/runtime/nodes/credentials', function() {

View File

@@ -20,11 +20,13 @@ var sinon = require('sinon');
var clone = require('clone');
var util = require("util");
var flowUtils = require("../../../../../red/runtime/nodes/flows/util");
var Flow = require("../../../../../red/runtime/nodes/flows/Flow");
var flows = require("../../../../../red/runtime/nodes/flows");
var Node = require("../../../../../red/runtime/nodes/Node");
var typeRegistry = require("../../../../../red/runtime-registry");
var NR_TEST_UTILS = require("nr-test-utils");
var flowUtils = NR_TEST_UTILS.require("@node-red/runtime/lib/nodes/flows/util");
var Flow = NR_TEST_UTILS.require("@node-red/runtime/lib/nodes/flows/Flow");
var flows = NR_TEST_UTILS.require("@node-red/runtime/lib/nodes/flows");
var Node = NR_TEST_UTILS.require("@node-red/runtime/lib/nodes/Node");
var typeRegistry = NR_TEST_UTILS.require("@node-red/registry");
describe('Flow', function() {

View File

@@ -18,13 +18,15 @@ var should = require("should");
var sinon = require("sinon");
var when = require("when");
var clone = require("clone");
var flows = require("../../../../../red/runtime/nodes/flows");
var RedNode = require("../../../../../red/runtime/nodes/Node");
var RED = require("../../../../../red/runtime/nodes");
var events = require("../../../../../red/runtime/events");
var credentials = require("../../../../../red/runtime/nodes/credentials");
var typeRegistry = require("../../../../../red/runtime-registry");
var Flow = require("../../../../../red/runtime/nodes/flows/Flow");
var NR_TEST_UTILS = require("nr-test-utils");
var flows = NR_TEST_UTILS.require("@node-red/runtime/lib/nodes/flows");
var RedNode = NR_TEST_UTILS.require("@node-red/runtime/lib/nodes/Node");
var RED = NR_TEST_UTILS.require("@node-red/runtime/lib/nodes");
var events = NR_TEST_UTILS.require("@node-red/runtime/lib/events");
var credentials = NR_TEST_UTILS.require("@node-red/runtime/lib/nodes/credentials");
var typeRegistry = NR_TEST_UTILS.require("@node-red/registry")
var Flow = NR_TEST_UTILS.require("@node-red/runtime/lib/nodes/flows/Flow");
describe('flows/index', function() {

View File

@@ -18,9 +18,10 @@ var should = require("should");
var sinon = require("sinon");
var when = require("when");
var clone = require("clone");
var flowUtil = require("../../../../../red/runtime/nodes/flows/util");
var typeRegistry = require("../../../../../red/runtime-registry");
var redUtil = require("../../../../../red/runtime/util");
var NR_TEST_UTILS = require("nr-test-utils");
var flowUtil = NR_TEST_UTILS.require("@node-red/runtime/lib/nodes/flows/util");
var typeRegistry = NR_TEST_UTILS.require("@node-red/registry");
var redUtil = NR_TEST_UTILS.require("@node-red/util").util;
describe('flows/util', function() {
var getType;

View File

@@ -21,15 +21,16 @@ var when = require("when");
var sinon = require('sinon');
var inherits = require("util").inherits;
var index = require("../../../../red/runtime/nodes/index");
var flows = require("../../../../red/runtime/nodes/flows");
var registry = require("../../../../red/runtime-registry");
var Node = require("../../../../red/runtime/nodes/Node");
var NR_TEST_UTILS = require("nr-test-utils");
var index = NR_TEST_UTILS.require("@node-red/runtime/lib/nodes/index");
var flows = NR_TEST_UTILS.require("@node-red/runtime/lib/nodes/flows");
var registry = NR_TEST_UTILS.require("@node-red/registry")
var Node = NR_TEST_UTILS.require("@node-red/runtime/lib/nodes/Node");
describe("red/nodes/index", function() {
before(function() {
sinon.stub(index,"startFlows");
process.env.NODE_RED_HOME = path.resolve(path.join(__dirname,"..","..","..",".."))
process.env.NODE_RED_HOME = NR_TEST_UTILS.resolve("node-red");
});
after(function() {
index.startFlows.restore();
@@ -168,11 +169,11 @@ describe("red/nodes/index", function() {
var http = require('http');
var express = require('express');
var app = express();
var runtime = require("../../../../red/runtime");
var credentials = require("../../../../red/runtime/nodes/credentials");
var localfilesystem = require("../../../../red/runtime/storage/localfilesystem");
var log = require("../../../../red/util/log");
var RED = require("../../../../red/red.js");
var runtime = NR_TEST_UTILS.require("@node-red/runtime");
var credentials = NR_TEST_UTILS.require("@node-red/runtime/lib/nodes/credentials");
var localfilesystem = NR_TEST_UTILS.require("@node-red/runtime/lib/storage/localfilesystem");
var log = NR_TEST_UTILS.require("@node-red/util").log;
var RED = NR_TEST_UTILS.require("node-red/lib/red.js");
var userDir = path.join(__dirname,".testUserHome");
before(function(done) {

View File

@@ -15,7 +15,8 @@
**/
var should = require("should");
var settings = require("../../../red/runtime/settings");
var NR_TEST_UTILS = require("nr-test-utils");
var settings = NR_TEST_UTILS.require("@node-red/runtime/lib/settings");
describe("red/settings", function() {

View File

@@ -16,7 +16,10 @@
var when = require("when");
var should = require("should");
var paff = require('path');
var storage = require("../../../../red/runtime/storage/index");
var NR_TEST_UTILS = require("nr-test-utils");
var storage = NR_TEST_UTILS.require("@node-red/runtime/lib/storage/index");
describe("red/storage/index", function() {

View File

@@ -18,9 +18,10 @@ var should = require("should");
var fs = require('fs-extra');
var path = require('path');
var sinon = require('sinon');
var NR_TEST_UTILS = require("nr-test-utils");
var localfilesystem = require("../../../../../red/runtime/storage/localfilesystem");
var log = require("../../../../../red/util/log");
var localfilesystem = NR_TEST_UTILS.require("@node-red/runtime/lib/storage/localfilesystem");
var log = NR_TEST_UTILS.require("@node-red/util").log;
describe('storage/localfilesystem', function() {
var mockRuntime = {

View File

@@ -17,8 +17,9 @@
var should = require("should");
var fs = require('fs-extra');
var path = require('path');
var NR_TEST_UTILS = require("nr-test-utils");
var localfilesystemLibrary = require("../../../../../red/runtime/storage/localfilesystem/library");
var localfilesystemLibrary = NR_TEST_UTILS.require("@node-red/runtime/lib/storage/localfilesystem/library");
describe('storage/localfilesystem/library', function() {
var userDir = path.join(__dirname,".testUserHome");

View File

@@ -14,6 +14,8 @@
* limitations under the License.
**/
var NR_TEST_UTILS = require("nr-test-utils");
describe("storage/localfilesystem/projects/Project", function() {
it.skip("NEEDS TESTS WRITING",function() {});
})

View File

@@ -16,7 +16,8 @@
var should = require("should");
var defaultFileSet = require("../../../../../../red/runtime/storage/localfilesystem/projects/defaultFileSet");
var NR_TEST_UTILS = require("nr-test-utils");
var defaultFileSet = NR_TEST_UTILS.require("@node-red/runtime/lib/storage/localfilesystem/projects/defaultFileSet");
describe('storage/localfilesystem/projects/defaultFileSet', function() {
var runtime = {

View File

@@ -17,7 +17,8 @@
var should = require("should");
var sinon = require("sinon");
var authCache = require("../../../../../../../red/runtime/storage/localfilesystem/projects/git/authCache")
var NR_TEST_UTILS = require("nr-test-utils");
var authCache = NR_TEST_UTILS.require("@node-red/runtime/lib/storage/localfilesystem/projects/git/authCache")
describe("localfilesystem/projects/git/authCache", function() {

View File

@@ -22,7 +22,9 @@ var sinon = require("sinon");
var child_process = require("child_process");
var fs = require("fs-extra");
var authServer = require("../../../../../../../red/runtime/storage/localfilesystem/projects/git/authServer");
var NR_TEST_UTILS = require("nr-test-utils");
var authServer = NR_TEST_UTILS.require("@node-red/runtime/lib/storage/localfilesystem/projects/git/authServer");
var sendPrompt = function(localPath, prompt) {

View File

@@ -22,7 +22,9 @@ var sinon = require("sinon");
var child_process = require("child_process");
var fs = require("fs-extra");
var authWriter = "../../../../../../../red/runtime/storage/localfilesystem/projects/git/authWriter";
var NR_TEST_UTILS = require("nr-test-utils");
var authWriter = NR_TEST_UTILS.resolve("@node-red/runtime/lib/storage/localfilesystem/projects/git/authWriter");
function getListenPath() {
var seed = (0x100000+Math.random()*0x999999).toString(16);

View File

@@ -14,6 +14,8 @@
* limitations under the License.
**/
var NR_TEST_UTILS = require("nr-test-utils");
describe("storage/localfilesystem/projects/git/index", function() {
it.skip("NEEDS TESTS WRITING",function() {});
})

View File

@@ -14,6 +14,8 @@
* limitations under the License.
**/
var NR_TEST_UTILS = require("nr-test-utils");
describe("storage/localfilesystem/projects/index", function() {
it.skip("NEEDS TESTS WRITING",function() {});
})

View File

@@ -17,7 +17,8 @@ var should = require("should");
var fs = require('fs-extra');
var path = require('path');
var sshkeys = require("../../../../../../../red/runtime/storage/localfilesystem/projects/ssh");
var NR_TEST_UTILS = require("nr-test-utils");
var sshkeys = NR_TEST_UTILS.require("@node-red/runtime/lib/storage/localfilesystem/projects/ssh");
describe("storage/localfilesystem/projects/ssh", function() {
var userDir = path.join(__dirname,".testSSHKeyUserHome");

View File

@@ -19,7 +19,8 @@ var sinon = require("sinon");
var child_process = require('child_process');
var EventEmitter = require("events");
var keygen = require("../../../../../../../red/runtime/storage/localfilesystem/projects/ssh/keygen")
var NR_TEST_UTILS = require("nr-test-utils");
var keygen = NR_TEST_UTILS.require("@node-red/runtime/lib/storage/localfilesystem/projects/ssh/keygen")
describe("localfilesystem/projects/ssh/keygen", function() {

View File

@@ -18,7 +18,8 @@ var should = require("should");
var fs = require('fs-extra');
var path = require('path');
var localfilesystemSessions = require("../../../../../red/runtime/storage/localfilesystem/sessions");
var NR_TEST_UTILS = require("nr-test-utils");
var localfilesystemSessions = NR_TEST_UTILS.require("@node-red/runtime/lib/storage/localfilesystem/sessions");
describe('storage/localfilesystem/sessions', function() {
var userDir = path.join(__dirname,".testUserHome");

View File

@@ -18,7 +18,9 @@ var should = require("should");
var fs = require('fs-extra');
var path = require('path');
var localfilesystemSettings = require("../../../../../red/runtime/storage/localfilesystem/settings");
var NR_TEST_UTILS = require("nr-test-utils");
var localfilesystemSettings = NR_TEST_UTILS.require("@node-red/runtime/lib/storage/localfilesystem/settings");
describe('storage/localfilesystem/settings', function() {
var userDir = path.join(__dirname,".testUserHome");

View File

@@ -15,7 +15,8 @@
**/
var should = require("should");
var util = require("../../../../../red/runtime/storage/localfilesystem/util");
var NR_TEST_UTILS = require("nr-test-utils");
var util = NR_TEST_UTILS.require("@node-red/runtime/lib/storage/localfilesystem/util");
describe('storage/localfilesystem/util', function() {
describe('parseJSON', function() {