Skip to content

Commit a2c2d13

Browse files
awadhanapetermetz
authored andcommitted
test: jestify runtime-plugin-import test
Migrated test from Tap to Jest. File Path: packages/cactus-test-cmd-api-server/src/test/typescript/integration/runtime-plugin-imports.test.ts This is a PARTIAL resolution to issue #238 Signed-off-by: awadhana <[email protected]>
1 parent 2cb68c3 commit a2c2d13

File tree

3 files changed

+53
-45
lines changed

3 files changed

+53
-45
lines changed

.taprc

-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ files:
4141
- ./packages/cactus-test-cmd-api-server/src/test/typescript/integration/remote-plugin-imports.test.ts
4242
- ./packages/cactus-test-cmd-api-server/src/test/typescript/integration/plugin-import-with-npm-install.test.ts
4343
- ./packages/cactus-test-cmd-api-server/src/test/typescript/integration/plugin-import-with-npm-install-version-selection.test.ts
44-
- ./packages/cactus-test-cmd-api-server/src/test/typescript/integration/runtime-plugin-imports.test.ts
4544
- ./packages/cactus-plugin-ledger-connector-corda/src/test/typescript/integration/openapi/openapi-validation.test.ts
4645
- ./packages/cactus-plugin-ledger-connector-corda/src/test/typescript/integration/deploy-cordapp-jars-to-nodes-v4.7.test.ts
4746
- ./packages/cactus-plugin-ledger-connector-corda/src/test/typescript/integration/jvm-kotlin-spring-server-v4.7.test.ts

jest.config.js

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import path from "path";
2-
import test, { Test } from "tape-promise/tape";
32
import { v4 as uuidv4 } from "uuid";
4-
3+
import "jest-extended";
54
import { LogLevelDesc } from "@hyperledger/cactus-common";
6-
75
import {
86
ApiServer,
97
AuthorizationProtocol,
@@ -15,47 +13,59 @@ import {
1513
} from "@hyperledger/cactus-core-api";
1614

1715
const logLevel: LogLevelDesc = "TRACE";
18-
19-
test("can import plugins at runtime (CLI)", async (t: Test) => {
20-
const pluginsPath = path.join(
21-
__dirname, // start at the current file's path
22-
"../../../../../../", // walk back up to the project root
23-
".tmp/test/cmd-api-server/runtime-plugin-imports_test", // the dir path from the root
24-
uuidv4(), // then a random directory to ensure proper isolation
25-
);
26-
const pluginManagerOptionsJson = JSON.stringify({ pluginsPath });
27-
28-
const configService = new ConfigService();
29-
const apiServerOptions = await configService.newExampleConfig();
30-
apiServerOptions.authorizationProtocol = AuthorizationProtocol.NONE;
31-
apiServerOptions.pluginManagerOptionsJson = pluginManagerOptionsJson;
32-
apiServerOptions.configFile = "";
33-
apiServerOptions.apiCorsDomainCsv = "*";
34-
apiServerOptions.apiPort = 0;
35-
apiServerOptions.cockpitPort = 0;
36-
apiServerOptions.grpcPort = 0;
37-
apiServerOptions.apiTlsEnabled = false;
38-
apiServerOptions.plugins = [
39-
{
40-
packageName: "@hyperledger/cactus-plugin-keychain-memory",
41-
type: PluginImportType.Local,
42-
action: PluginImportAction.Install,
43-
options: {
44-
instanceId: uuidv4(),
45-
keychainId: uuidv4(),
46-
logLevel,
16+
const testCase = "can import plugins at runtime (CLI)";
17+
describe(testCase, () => {
18+
let apiServer: ApiServer;
19+
test(testCase, async () => {
20+
const pluginsPath = path.join(
21+
__dirname, // start at the current file's path
22+
"../../../../../../", // walk back up to the project root
23+
".tmp/test/cmd-api-server/runtime-plugin-imports_test", // the dir path from the root
24+
uuidv4(), // then a random directory to ensure proper isolation
25+
);
26+
const pluginManagerOptionsJson = JSON.stringify({ pluginsPath });
27+
const configService = new ConfigService();
28+
const apiServerOptions = await configService.newExampleConfig();
29+
apiServerOptions.authorizationProtocol = AuthorizationProtocol.NONE;
30+
apiServerOptions.pluginManagerOptionsJson = pluginManagerOptionsJson;
31+
apiServerOptions.configFile = "";
32+
apiServerOptions.apiCorsDomainCsv = "*";
33+
apiServerOptions.apiPort = 0;
34+
apiServerOptions.cockpitPort = 0;
35+
apiServerOptions.grpcPort = 0;
36+
apiServerOptions.apiTlsEnabled = false;
37+
apiServerOptions.plugins = [
38+
{
39+
packageName: "@hyperledger/cactus-plugin-keychain-memory",
40+
type: PluginImportType.Local,
41+
action: PluginImportAction.Install,
42+
options: {
43+
instanceId: uuidv4(),
44+
keychainId: uuidv4(),
45+
logLevel,
46+
},
4747
},
48-
},
49-
];
50-
const config = await configService.newExampleConfigConvict(apiServerOptions);
48+
];
49+
const config = await configService.newExampleConfigConvict(
50+
apiServerOptions,
51+
);
5152

52-
const apiServer = new ApiServer({
53-
config: config.getProperties(),
53+
apiServer = new ApiServer({
54+
config: config.getProperties(),
55+
});
56+
apiServerOptions.plugins = [
57+
{
58+
packageName: "@hyperledger/cactus-plugin-keychain-memory",
59+
type: PluginImportType.Local,
60+
action: PluginImportAction.Install,
61+
options: {
62+
instanceId: uuidv4(),
63+
keychainId: uuidv4(),
64+
logLevel,
65+
},
66+
},
67+
];
68+
await expect(apiServer.start()).not.toReject();
5469
});
55-
56-
await t.doesNotReject(
57-
apiServer.start(),
58-
"failed to start API server with dynamic plugin imports configured for it...",
59-
);
60-
test.onFinish(() => apiServer.shutdown());
70+
afterAll(async () => await apiServer.shutdown());
6171
});

0 commit comments

Comments
 (0)