Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
kristiandupont committed Sep 23, 2020
1 parent 8e585fe commit 51f9704
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 33 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"pg": "^8.2.1",
"prettier": "^2.0.5",
"testcontainers": "^2.18.2",
"ts-jest": "^26.1.1",
"ts-jest": "^26.4.0",
"typescript": "^4.0.3"
},
"files": [
Expand Down
34 changes: 17 additions & 17 deletions src/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,26 @@ const { GenericContainer, Wait } = require('testcontainers');
const { Duration, TemporalUnit } = require('node-duration');
const index = require('./index');

const containerLogPrefix = "postgres-container>>> ";
const containerLogPrefix = 'postgres-container>>> ';
let pgContainer = new GenericContainer('postgres')
.withExposedPorts(5432)
.withEnv('POSTGRES_PASSWORD', 'postgres')
.withStartupTimeout()
.withWaitStrategy(
Wait.forLogMessage('database system is ready to accept connections')
);
.withExposedPorts(5432)
.withEnv('POSTGRES_PASSWORD', 'postgres')
.withStartupTimeout()
.withWaitStrategy(
Wait.forLogMessage('database system is ready to accept connections')
);
let config;

beforeAll(async () => {
jest.setTimeout(30000);
pgContainer = await pgContainer.start();
const stream = await pgContainer.logs();
stream
.on("data", line => console.log(containerLogPrefix + line))
.on("err", line => console.error(containerLogPrefix + line))
.on("end", () => console.log(containerLogPrefix + "Stream closed"));
// .on('data', (line) => console.log(containerLogPrefix + line))
.on('err', (line) => console.error(containerLogPrefix + line))
.on('end', () => console.log(containerLogPrefix + 'Stream closed'));
config = {
client: 'postgres',
debug: true,
connection: {
host: pgContainer.getContainerIpAddress(),
database: 'postgres',
Expand Down Expand Up @@ -92,11 +91,12 @@ test('in default schema', async () => {
expect(extracted.views.length).toBe(1);
expect(extracted.views[0].name).toBe('default_view');

expect(extracted.types.length).toBe(2);
expect(extracted.types.filter((t) => t.name === 'cust_type')).not.toBeNull();
console.log(extracted.types);
expect(extracted.types.length).toBe(1);
expect(extracted.types.filter((t) => t.name === 'cust_type')).toHaveLength(1);
expect(
extracted.types.filter((t) => t.name === 'cust_type_not_default')
).not.toBeNull();
).toHaveLength(0);
});

test('in not default schema', async () => {
Expand All @@ -109,9 +109,9 @@ test('in not default schema', async () => {
expect(extracted.views.length).toBe(1);
expect(extracted.views[0].name).toBe('not_default_view');

expect(extracted.types.length).toBe(2);
expect(extracted.types.filter((t) => t.name === 'cust_type')).not.toBeNull();
expect(extracted.types.length).toBe(1);
expect(extracted.types.filter((t) => t.name === 'cust_type')).toHaveLength(0);
expect(
extracted.types.filter((t) => t.name === 'cust_type_not_default')
).not.toBeNull();
).toHaveLength(1);
});
44 changes: 29 additions & 15 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,14 @@
"@types/istanbul-lib-coverage" "*"
"@types/istanbul-lib-report" "*"

"@types/[email protected]":
version "26.0.14"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-26.0.14.tgz#078695f8f65cb55c5a98450d65083b2b73e5a3f3"
integrity sha512-Hz5q8Vu0D288x3iWXePSn53W7hAjP0H7EQ6QvDO9c7t46mR0lNOLlfuwQ+JkVxuhygHzlzPX+0jKdA3ZgSh+Vg==
dependencies:
jest-diff "^25.2.1"
pretty-format "^25.2.1"

"@types/jest@^26.0.4":
version "26.0.4"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-26.0.4.tgz#d2e513e85aca16992816f192582b5e67b0b15efb"
Expand Down Expand Up @@ -3765,14 +3773,6 @@ merge-stream@^2.0.0:
resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60"
integrity sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==

[email protected], micromatch@^4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.2.tgz#4fcb0999bf9fbc2fcbdd212f6d629b9a56c39259"
integrity sha512-y7FpHSbMUMoyPbYUSzO6PaZ6FyRnQOpHuKwbo1G+Knck95XVU4QAiKdGEnj5wwoS7PlOgthX/09u5iFJ+aYf5Q==
dependencies:
braces "^3.0.1"
picomatch "^2.0.5"

micromatch@^3.0.4, micromatch@^3.1.4:
version "3.1.10"
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-3.1.10.tgz#70859bc95c9840952f359a068a3fc49f9ecfac23"
Expand All @@ -3792,6 +3792,14 @@ micromatch@^3.0.4, micromatch@^3.1.4:
snapdragon "^0.8.1"
to-regex "^3.0.2"

micromatch@^4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.2.tgz#4fcb0999bf9fbc2fcbdd212f6d629b9a56c39259"
integrity sha512-y7FpHSbMUMoyPbYUSzO6PaZ6FyRnQOpHuKwbo1G+Knck95XVU4QAiKdGEnj5wwoS7PlOgthX/09u5iFJ+aYf5Q==
dependencies:
braces "^3.0.1"
picomatch "^2.0.5"

[email protected]:
version "1.44.0"
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.44.0.tgz#fa11c5eb0aca1334b4233cb4d52f10c5a6272f92"
Expand Down Expand Up @@ -5531,21 +5539,22 @@ trim-newlines@^3.0.0:
resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-3.0.0.tgz#79726304a6a898aa8373427298d54c2ee8b1cb30"
integrity sha512-C4+gOpvmxaSMKuEf9Qc134F1ZuOHVXKRbtEflf4NTtuuJDEIJ9p5PXsalL8SkeRw+qit1Mo+yuvMPAKwWg/1hA==

ts-jest@^26.1.1:
version "26.1.1"
resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-26.1.1.tgz#b98569b8a4d4025d966b3d40c81986dd1c510f8d"
integrity sha512-Lk/357quLg5jJFyBQLnSbhycnB3FPe+e9i7ahxokyXxAYoB0q1pPmqxxRPYr4smJic1Rjcf7MXDBhZWgxlli0A==
ts-jest@^26.4.0:
version "26.4.0"
resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-26.4.0.tgz#903c7827f3d3bc33efc2f91be294b164400c32e3"
integrity sha512-ofBzoCqf6Nv/PoWb/ByV3VNKy2KJSikamOBxvR3E6eVdIw10GwAXoyvMWXXjZJK2s6S27ZE8fI+JBTnGaovl6Q==
dependencies:
"@types/jest" "26.x"
bs-logger "0.x"
buffer-from "1.x"
fast-json-stable-stringify "2.x"
jest-util "^26.1.0"
json5 "2.x"
lodash.memoize "4.x"
make-error "1.x"
micromatch "4.x"
mkdirp "1.x"
semver "7.x"
yargs-parser "18.x"
yargs-parser "20.x"

ts-toolbelt@^6.3.3:
version "6.9.9"
Expand Down Expand Up @@ -5937,7 +5946,12 @@ yaml@^1.7.2:
resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.0.tgz#3b593add944876077d4d683fee01081bd9fff31e"
integrity sha512-yr2icI4glYaNG+KWONODapy2/jDdMSDnrONSjblABjD9B4Z5LgiircSt8m8sRZFNi08kG9Sm0uSHtEmP3zaEGg==

[email protected], yargs-parser@^18.1.2, yargs-parser@^18.1.3:
[email protected]:
version "20.2.0"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.0.tgz#944791ca2be2e08ddadd3d87e9de4c6484338605"
integrity sha512-2agPoRFPoIcFzOIp6656gcvsg2ohtscpw2OINr/q46+Sq41xz2OYLqx5HRHabmFU1OARIPAYH5uteICE7mn/5A==

yargs-parser@^18.1.2, yargs-parser@^18.1.3:
version "18.1.3"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-18.1.3.tgz#be68c4975c6b2abf469236b0c870362fab09a7b0"
integrity sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==
Expand Down

0 comments on commit 51f9704

Please sign in to comment.