Skip to content

Commit

Permalink
Tweak posttest scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
benjie committed Oct 4, 2024
1 parent 40b1546 commit bf60936
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/test-base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ jobs:
PGPASSWORD: postgres
PGHOST: localhost
PGVERSION: ${{ matrix.postgres-version}}
ROOT_DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres
TEST_DATABASE_URL: postgres://postgres:postgres@localhost:5432/graphileengine_test
TEST_PG_URL: postgres://postgres:postgres@localhost:5432/postgraphile_test
LDS_TEST_DATABASE_URL: postgres://postgres:postgres@localhost:5432/lds_test
TEST_SIMPLIFY_DATABASE_URL: postgres://postgres:postgres@localhost:5432/pg_simplify_inflectors
TERM: xterm
FORCE_COLOR: 1
Expand Down
9 changes: 7 additions & 2 deletions grafast/dataplan-pg/scripts/runExampleSchema.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@ import JSON5 from "json5";

import { schema } from "./exampleSchemaExport.mjs";

const connectionString =
process.env.TEST_DATABASE_URL || "postgres:///graphile_crystal";
const databaseName = "graphilecrystaltest";
const host = process.env.PGHOST ?? "localhost";
const connectionString = host.includes("/")
? `socket://graphilecrystaltest:test@${host}?db=${encodeURIComponent(
databaseName,
)}`
: `postgres://graphilecrystaltest:test@${host}/${databaseName}`;
const pgService = makePgService({ connectionString });
const preset = {
plugins: [PgContextPlugin],
Expand Down
3 changes: 1 addition & 2 deletions grafast/dataplan-pg/serve-example-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ const { createWithPgClient } = require("./dist/adaptors/pg");

const schema = makeExampleSchema();
const withPgClient = createWithPgClient({
connectionString:
process.env.TEST_DATABASE_URL || "postgres:///graphile_crystal",
connectionString: "postgres:///graphilecrystaltest",
});
const serv = grafserv({
preset: { grafast: { context: { withPgClient }, explain: true } },
Expand Down
3 changes: 3 additions & 0 deletions scripts/pretest
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ fi;

SERVER_VERSION_NUM=$(psql -XAqtv ON_ERROR_STOP=1 -d "${OWNER_DATABASE:-postgres}" -c "show server_version_num;")

psql -Xqv ON_ERROR_STOP=1 -d "${OWNER_DATABASE:-postgres}" -c "drop database graphilecrystaltest;" || true
for DBNAME in $(psql -XAqtv ON_ERROR_STOP=1 -d "${OWNER_DATABASE:-postgres}" -c "select datname from pg_database where datname like 'gctestdb_%' and datname = format('%I', datname);"); do
echo "DEL $DBNAME"
psql -Xqv ON_ERROR_STOP=1 -d "${OWNER_DATABASE:-postgres}" -c "drop database $DBNAME;"
Expand Down Expand Up @@ -57,5 +58,7 @@ PGPASSWORD=test psql -Xqv ON_ERROR_STOP=1 -d "graphilecrystaltest_template" -U g
#HERE
#psql -X1v ON_ERROR_STOP=1 -v VERBOSITY=verbose -d lds_test -f utils/lds/__tests__/schema.sql

psql -Xqv ON_ERROR_STOP=1 -d "${OWNER_DATABASE:-postgres}" -c "create database graphilecrystaltest with template = graphilecrystaltest_template owner = graphilecrystaltest;"

clear
echo "Database reset successfully ✅"

0 comments on commit bf60936

Please sign in to comment.