diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4ce1f2261c..06dfcbab85 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -2469,7 +2469,7 @@ jobs: JEST_TEST_COVERAGE_PATH: ./code-coverage-ts/cactus-test-tooling JEST_TEST_CODE_COVERAGE_ENABLED: true TAPE_TEST_PATTERN: >- - --files={./packages/cactus-test-tooling/src/test/typescript/integration/besu/besu-test-ledger/constructor-validates-options.test.ts,./packages/cactus-test-tooling/src/test/typescript/integration/fabric/fabric-test-ledger-v1/constructor-validates-options.test.ts,./packages/cactus-test-tooling/src/test/typescript/integration/postgres/postgres-test-container/constructor-validates-options.test.ts,./packages/cactus-test-tooling/src/test/typescript/integration/substrate/substrate-test-ledger-constructor.test.ts,./packages/cactus-test-tooling/src/test/typescript/integration/substrate/substrate-test-ledger-multiple-concurrent.test.ts} + --files={./packages/cactus-test-tooling/src/test/typescript/integration/besu/besu-test-ledger/constructor-validates-options.test.ts,./packages/cactus-test-tooling/src/test/typescript/integration/fabric/fabric-test-ledger-v1/constructor-validates-options.test.ts,./packages/cactus-test-tooling/src/test/typescript/integration/substrate/substrate-test-ledger-constructor.test.ts,./packages/cactus-test-tooling/src/test/typescript/integration/substrate/substrate-test-ledger-multiple-concurrent.test.ts} TAPE_TEST_RUNNER_DISABLED: false runs-on: ubuntu-22.04 steps: diff --git a/.taprc b/.taprc index 4708a6f5bf..778acc0186 100644 --- a/.taprc +++ b/.taprc @@ -44,7 +44,6 @@ files: - ./packages/cactus-plugin-keychain-vault/src/test/typescript/integration/cactus-keychain-vault-server.test.ts - ./packages/cactus-plugin-keychain-vault/src/test/typescript/integration/plugin-keychain-vault.test.ts - ./packages/cactus-plugin-keychain-vault/src/test/typescript/integration/openapi/openapi-validation.test.ts - - ./packages/cactus-test-tooling/src/test/typescript/integration/postgres/postgres-test-container/constructor-validates-options.test.ts - ./packages/cactus-test-tooling/src/test/typescript/integration/fabric/fabric-test-ledger-v1/constructor-validates-options.test.ts - ./packages/cactus-test-tooling/src/test/typescript/integration/substrate/substrate-test-ledger-constructor.test.ts - ./packages/cactus-test-tooling/src/test/typescript/integration/substrate/substrate-test-ledger-multiple-concurrent.test.ts diff --git a/jest.config.js b/jest.config.js index c42adbdcab..d369e76fe6 100644 --- a/jest.config.js +++ b/jest.config.js @@ -56,7 +56,6 @@ module.exports = { `./packages/cactus-plugin-keychain-vault/src/test/typescript/integration/cactus-keychain-vault-server.test.ts`, `./packages/cactus-plugin-keychain-vault/src/test/typescript/integration/plugin-keychain-vault.test.ts`, `./packages/cactus-plugin-keychain-vault/src/test/typescript/integration/openapi/openapi-validation.test.ts`, - `./packages/cactus-test-tooling/src/test/typescript/integration/postgres/postgres-test-container/constructor-validates-options.test.ts`, `./packages/cactus-test-tooling/src/test/typescript/integration/fabric/fabric-test-ledger-v1/constructor-validates-options.test.ts`, `./packages/cactus-test-tooling/src/test/typescript/integration/substrate/substrate-test-ledger-constructor.test.ts`, `./packages/cactus-test-tooling/src/test/typescript/integration/substrate/substrate-test-ledger-multiple-concurrent.test.ts`, diff --git a/packages/cactus-test-tooling/src/test/typescript/integration/postgres/postgres-test-container/constructor-validates-options.test.ts b/packages/cactus-test-tooling/src/test/typescript/integration/postgres/postgres-test-container/constructor-validates-options.test.ts index d2bd7938a1..217fbf6c7e 100644 --- a/packages/cactus-test-tooling/src/test/typescript/integration/postgres/postgres-test-container/constructor-validates-options.test.ts +++ b/packages/cactus-test-tooling/src/test/typescript/integration/postgres/postgres-test-container/constructor-validates-options.test.ts @@ -1,42 +1,46 @@ -import test, { Test } from "tape-promise/tape"; +import "jest-extended"; import isPortReachable from "is-port-reachable"; import { Container } from "dockerode"; import { PostgresTestContainer } from "../../../../../main/typescript/public-api"; import { LogLevelDesc } from "@hyperledger/cactus-common"; -const logLevel: LogLevelDesc = "TRACE"; +const logLevel: LogLevelDesc = "INFO"; -test("constructor throws if invalid input is provided", (assert: Test) => { - assert.ok(PostgresTestContainer); - assert.throws(() => new PostgresTestContainer({ imageVersion: "nope" })); - assert.end(); -}); - -test("constructor does not throw if valid input is provided", (assert: Test) => { - assert.ok(PostgresTestContainer); - assert.doesNotThrow(() => new PostgresTestContainer()); - assert.end(); -}); - -test("starts/stops/destroys a docker container", async (assert: Test) => { +describe("PostgresTestContainer", () => { const postgresTestContainer = new PostgresTestContainer({ logLevel }); + let postgresContainer: Container; + + beforeAll(async () => { + postgresContainer = await postgresTestContainer.start(); + }); - const postgresContainer: Container = await postgresTestContainer.start(); - test.onFinish(async () => { + afterAll(async () => { await postgresTestContainer.stop(); }); - assert.ok(postgresContainer); - const ipAddress: string = await postgresTestContainer.getContainerIpAddress(); - assert.ok(ipAddress); - assert.ok(ipAddress.length); + it("constructor throws if invalid input is provided", () => { + expect(PostgresTestContainer).toBeTruthy(); + expect( + () => new PostgresTestContainer({ imageVersion: "nope" }), + ).toThrowError(); + }); - const hostPort: number = await postgresTestContainer.getPostgresPort(); - assert.ok(hostPort, "getRpcApiPublicPort() returns truthy OK"); - assert.ok(isFinite(hostPort), "getRpcApiPublicPort() returns finite OK"); + it("constructor does not throw if valid input is provided", () => { + expect(PostgresTestContainer).toBeTruthy(); + expect(() => new PostgresTestContainer()).not.toThrow(); + }); - const isReachable = await isPortReachable(hostPort, { host: "127.0.0.1" }); - assert.ok(isReachable, `HostPort ${hostPort} is reachable via 127.0.0.1`); + it("starts/stops/destroys a docker container", async () => { + expect(postgresContainer).toBeTruthy(); + const ip: string = await postgresTestContainer.getContainerIpAddress(); + expect(ip).toBeString(); + expect(ip).not.toBeEmpty(); - assert.end(); + const hostPort: number = await postgresTestContainer.getPostgresPort(); + expect(hostPort).toBeTruthy(); + expect(hostPort).toBeFinite(); + + const reachabilityCheck = isPortReachable(hostPort, { host: "127.0.0.1" }); + expect(reachabilityCheck).resolves.toBeTrue(); + }); });