This repository has been archived by the owner on Feb 22, 2023. It is now read-only.
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
Showing
10 changed files
with
176 additions
and
24 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
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 |
---|---|---|
@@ -1,17 +1,26 @@ | ||
#!/usr/bin/env node | ||
import * as program from "commander"; | ||
import {Global} from "../lib/core/global"; | ||
import {BstStatistics, BstCommand} from "../lib/statistics/bst-statistics"; | ||
|
||
const skillTesting = require("skill-testing-ml"); | ||
|
||
program.version(Global.version()); | ||
|
||
program | ||
.usage("[test-pattern-regex]") | ||
.description("Runs unit-tests for a skill - automatically searches for YML test files and runs them") | ||
.parse(process.argv); | ||
Global.initializeCLI(false).then(() => { | ||
|
||
const testCLI = new skillTesting.CLI(); | ||
testCLI.run(process.argv).then((success) => { | ||
process.exitCode = success ? 0 : 1; | ||
}); | ||
program | ||
.usage("[test-pattern-regex]") | ||
.description("Runs unit-tests for a skill - automatically searches for YML test files and runs them") | ||
.parse(process.argv); | ||
|
||
const testCLI = new skillTesting.CLI(); | ||
testCLI.run(process.argv).then((success) => { | ||
let nodeId = undefined; | ||
if (Global.config() && Global.config().secretKey && Global.config().secretKey()) { | ||
nodeId = Global.config().secretKey(); | ||
} | ||
BstStatistics.instance().record(BstCommand.test, undefined, nodeId); | ||
process.exitCode = success ? 0 : 1; | ||
}); | ||
}); |
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
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
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
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
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
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
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,69 @@ | ||
import * as assert from "assert"; | ||
import * as mockery from "mockery"; | ||
import * as sinon from "sinon"; | ||
import {NodeUtil} from "../../lib/core/node-util"; | ||
import {BSTProcess} from "../../lib/client/bst-config"; | ||
import {SinonSandbox} from "sinon"; | ||
|
||
describe("bst-speak", function() { | ||
|
||
let globalModule = { | ||
Global: { | ||
initializeCLI: sinon.spy(async function () { | ||
|
||
}), | ||
config: function () { | ||
return { sourceID: () => "mySource" }; | ||
}, | ||
running : function() { | ||
let p = new BSTProcess(); | ||
p.port = 9999; | ||
return p; | ||
}, | ||
|
||
version: function () { | ||
return "0.0.0"; | ||
} | ||
} | ||
}; | ||
|
||
let sandbox: SinonSandbox = null; | ||
beforeEach(function () { | ||
mockery.enable({useCleanCache: true}); | ||
mockery.warnOnUnregistered(false); | ||
mockery.warnOnReplace(false); | ||
mockery.registerMock("../lib/core/global", globalModule); | ||
sandbox = sinon.sandbox.create(); | ||
globalModule.Global.initializeCLI.reset(); | ||
}); | ||
|
||
afterEach(function () { | ||
sandbox.restore(); | ||
mockery.deregisterAll(); | ||
mockery.disable(); | ||
}); | ||
|
||
describe("test command", function() { | ||
it("call initializeCLI with false", function() { | ||
return new Promise((resolve, reject) => { | ||
|
||
process.argv = command("node bst-test.js"); | ||
mockery.registerMock("skill-testing-ml", { | ||
CLI: function() { | ||
return { | ||
run: async function () { | ||
} | ||
}; | ||
} | ||
}); | ||
NodeUtil.load("../../bin/bst-test.js"); | ||
assert.equal(globalModule.Global.initializeCLI.getCall(0).args[0], false); | ||
resolve(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
let command = function (command: string): Array<string> { | ||
return command.split(" "); | ||
}; |
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