@sprucelabs/spruce-cli
Version:
Command line interface for building Spruce skills.
57 lines • 2.97 kB
JavaScript
;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const test_utils_1 = require("@sprucelabs/test-utils");
const find_process_1 = __importDefault(require("find-process"));
const AbstractSkillTest_1 = __importDefault(require("../../../tests/AbstractSkillTest"));
class BootingASkillTest extends AbstractSkillTest_1.default {
static skillCacheKey = 'skills';
static async bootingWithoutBuildingThrowsGoodError() {
const results = await this.Action('skill', 'boot').execute({});
test_utils_1.assert.isTruthy(results.errors);
test_utils_1.assert.doesInclude(results.errors[0].message, /you must build/gis);
}
static async aSkillCanBeBootedAndKilled() {
await this.Service('build').build();
const response = await this.Action('skill', 'boot').execute({});
test_utils_1.assert.isFalsy(response.errors);
test_utils_1.assert.isTrue(response.meta?.isBooted);
const pid = response.meta?.pid;
test_utils_1.assert.isAbove(pid, 0);
const psResults = await (0, find_process_1.default)('pid', pid);
test_utils_1.assert.isAbove(psResults.length, 0);
response.meta?.kill();
await this.wait(1000);
const psResultsEmpty = await (0, find_process_1.default)('pid', pid);
test_utils_1.assert.isLength(psResultsEmpty, 0);
await response.meta?.promise;
}
static async canReturnFromExecuteImmediately() {
const response = await this.Action('skill', 'boot').execute({
shouldReturnImmediately: true,
});
test_utils_1.assert.isFalse(response.meta?.isBooted);
const bootResponse = await response.meta?.bootPromise;
test_utils_1.assert.isEqual(bootResponse.meta.pid, response.meta.pid);
test_utils_1.assert.isTrue(bootResponse.meta?.isBooted);
}
}
exports.default = BootingASkillTest;
__decorate([
(0, test_utils_1.test)()
], BootingASkillTest, "bootingWithoutBuildingThrowsGoodError", null);
__decorate([
(0, test_utils_1.test)()
], BootingASkillTest, "aSkillCanBeBootedAndKilled", null);
__decorate([
(0, test_utils_1.test)()
], BootingASkillTest, "canReturnFromExecuteImmediately", null);
//# sourceMappingURL=BootingASkill.test.js.map