Skip to content

Commit

Permalink
fix: fix ci workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ozum committed Mar 13, 2021
1 parent 8988396 commit 5779d08
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion github.env → .github/workflows/github.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
DB_DATABASE=example
DB_DATABASE=pg-generator-test
DB_HOST=localhost
DB_USER=user
DB_PASSWORD=password
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
run: |-
while read line; do
echo "$line" >> $GITHUB_ENV
done < github.env
done < .github/workflows/github.env
- name: Use Node 14
uses: actions/setup-node@v2
with:
Expand Down
6 changes: 1 addition & 5 deletions test/generate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const TEST_ROOT = join(tmpdir(), "pgen");
const outDir = join(TEST_ROOT, "out");
const outDir2 = join(TEST_ROOT, "out2");
const app = new App({ outDir }, { db: {}, templateDir: join(__dirname, "templates") } as any);
const CLIENT_OPTIONS = { database: "pg-generator-test", user: "user", password: "password" };

// WORKAROUND: Jest does not output error of dynamic import in (src/utils/compose-with.ts). This function rethrows error.
async function g(subGenerator = "app", options?: Options, { argLength = 3, cwd = "" } = {}): ReturnType<typeof load> {
Expand All @@ -25,7 +24,6 @@ async function g(subGenerator = "app", options?: Options, { argLength = 3, cwd =
log: false,
outDir,
relationNameFunctions: "optimal",
...CLIENT_OPTIONS,
...options,
};

Expand Down Expand Up @@ -116,9 +114,7 @@ describe("generate", () => {
});

it("should throw if generator cannot be found.", async () => {
await expect(() => generate("XYZ", { ...CLIENT_OPTIONS })).rejects.toThrow(
"You don't seem to have a generator with the name 'XYZ' installed."
);
await expect(() => generate("XYZ")).rejects.toThrow("You don't seem to have a generator with the name 'XYZ' installed.");
});

it("should throw if sub-generator cannot be found.", async () => {
Expand Down
6 changes: 6 additions & 0 deletions test/test-helper/global-setup.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { promises as fs, existsSync } from "fs";
import { join } from "path";
import PgTestUtil from "pg-test-util";

module.exports = async () => {
const envPath = join(__dirname, "../../.env");
const githubEnvPath = join(__dirname, "../../.github/workflows/github.env");
if (!existsSync(envPath)) await fs.copyFile(githubEnvPath, envPath);

const pgTestUtil = new PgTestUtil({ connection: { connectionString: "postgresql://user:[email protected]:5432/template1" } });
await pgTestUtil.createDatabase({ drop: true, name: "pg-generator-test", file: `${__dirname}/ddl/main.sql` });
(global as any).pgTestUtil = pgTestUtil;
Expand Down

0 comments on commit 5779d08

Please sign in to comment.