More consistent loading of the test fixtures (#1506)
Remove db setup from the Haskell test suite and include it in the test bash scripts.
This commit is contained in:
@@ -325,12 +325,6 @@ jobs:
|
||||
name: run memory usage tests
|
||||
command: |
|
||||
test/create_test_db "postgres://circleci@localhost" postgrest_test
|
||||
psql "postgres:///postgrest_test" -f test/fixtures/database.sql
|
||||
psql "postgres:///postgrest_test" -f test/fixtures/roles.sql
|
||||
psql "postgres:///postgrest_test" -f test/fixtures/schema.sql
|
||||
psql "postgres:///postgrest_test" -f test/fixtures/jwt.sql
|
||||
psql "postgres:///postgrest_test" -f test/fixtures/jsonschema.sql
|
||||
psql "postgres:///postgrest_test" -f test/fixtures/privileges.sql
|
||||
test/memory-tests.sh
|
||||
|
||||
centos7:
|
||||
|
||||
@@ -56,7 +56,6 @@ main = do
|
||||
getTime <- mkAutoUpdate defaultUpdateSettings { updateAction = getCurrentTime }
|
||||
|
||||
testDbConn <- getEnvVarWithDefault "POSTGREST_TEST_CONNECTION" "postgres://postgrest_test@localhost/postgrest_test"
|
||||
setupDb testDbConn
|
||||
|
||||
pool <- P.acquire (3, 10, toS testDbConn)
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ import Test.Hspec
|
||||
main :: IO ()
|
||||
main = do
|
||||
testDbConn <- getEnvVarWithDefault "POSTGREST_TEST_CONNECTION" "postgres://postgrest_test@localhost/postgrest_test"
|
||||
-- To speed things up, assume setupDb has ben ran in the previous spec.
|
||||
pool <- P.acquire (3, 10, toS testDbConn)
|
||||
|
||||
hspec $ describe "QueryCost" $
|
||||
|
||||
@@ -145,16 +145,6 @@ testCfgResponseHeaders testDbConn = (testCfg testDbConn) { configReqCheck = Just
|
||||
testMultipleSchemaCfg :: Text -> AppConfig
|
||||
testMultipleSchemaCfg testDbConn = (testCfg testDbConn) { configSchemas = fromList ["v1", "v2"] }
|
||||
|
||||
setupDb :: Text -> IO ()
|
||||
setupDb dbConn = do
|
||||
loadFixture dbConn "database"
|
||||
loadFixture dbConn "roles"
|
||||
loadFixture dbConn "schema"
|
||||
loadFixture dbConn "jwt"
|
||||
loadFixture dbConn "jsonschema"
|
||||
loadFixture dbConn "privileges"
|
||||
resetDb dbConn
|
||||
|
||||
resetDb :: Text -> IO ()
|
||||
resetDb dbConn = loadFixture dbConn "data"
|
||||
|
||||
|
||||
@@ -55,6 +55,8 @@ ALTER DATABASE $DB SET LC_MESSAGES = 'POSIX';
|
||||
ALTER DATABASE $DB SET LC_MONETARY = 'POSIX';
|
||||
ALTER DATABASE $DB SET LC_NUMERIC = 'POSIX';
|
||||
ALTER DATABASE $DB SET LC_TIME = 'POSIX';
|
||||
|
||||
\i $BASEPATH/fixtures/load.sql
|
||||
EOF
|
||||
|
||||
#Remove database path from the connection uri--prevents setting up the new database name with PGDATABASE
|
||||
|
||||
Vendored
+1
-1
@@ -20,7 +20,7 @@ HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
|
||||
MODIFICATIONS.
|
||||
*/
|
||||
|
||||
CREATE OR REPLACE FUNCTION _validate_json_schema_type(type text, data jsonb) RETURNS boolean AS $f$
|
||||
CREATE OR REPLACE FUNCTION public._validate_json_schema_type(type text, data jsonb) RETURNS boolean AS $f$
|
||||
BEGIN
|
||||
IF type = 'integer' THEN
|
||||
IF jsonb_typeof(data) != 'number' THEN
|
||||
|
||||
Vendored
+3
@@ -1,5 +1,8 @@
|
||||
-- From michelp/pgjwt commit c02bbd3
|
||||
BEGIN;
|
||||
|
||||
set search_path to public;
|
||||
|
||||
set client_min_messages to warning;
|
||||
DROP SCHEMA IF EXISTS jwt CASCADE;
|
||||
CREATE SCHEMA jwt;
|
||||
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
-- Loads all fixtures for the PostgREST tests
|
||||
|
||||
\set ON_ERROR_STOP on
|
||||
|
||||
\ir database.sql
|
||||
\ir roles.sql
|
||||
\ir schema.sql
|
||||
\ir jwt.sql
|
||||
\ir jsonschema.sql
|
||||
\ir privileges.sql
|
||||
\ir data.sql
|
||||
+1
-8
@@ -35,7 +35,6 @@ if [ "$#" -lt 1 ]; then
|
||||
fi
|
||||
|
||||
rootdir="$(git rev-parse --show-toplevel)"
|
||||
fixturesdir="$rootdir/test/fixtures"
|
||||
|
||||
# All data will be stored in a temporary directory.
|
||||
tmpdir="$(mktemp -d)"
|
||||
@@ -97,13 +96,7 @@ psql -v ON_ERROR_STOP=1 >> "$setuplog" << EOF
|
||||
create extension pgcrypto;
|
||||
alter database $PGDATABASE set request.jwt.claim.id = '-1';
|
||||
alter role $PGUSER set default_text_search_config to english;
|
||||
|
||||
\i $fixturesdir/database.sql
|
||||
\i $fixturesdir/roles.sql
|
||||
\i $fixturesdir/schema.sql
|
||||
\i $fixturesdir/jwt.sql
|
||||
\i $fixturesdir/jsonschema.sql
|
||||
\i $fixturesdir/privileges.sql
|
||||
\i $rootdir/test/fixtures/load.sql
|
||||
EOF
|
||||
|
||||
log "Done. Running command..."
|
||||
|
||||
Reference in New Issue
Block a user