diff --git a/.circleci/config.yml b/.circleci/config.yml index 39e9ffb..93ff3b8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,6 +7,7 @@ jobs: PGUSER: pgx PGDATABASE: pgx-test PGHOST: 127.0.0.1 + PGX_FORCE_TESTS: true TERM: xterm - image: circleci/postgres:9.6-alpine environment: diff --git a/pgx_test/src/pgx_test.ml b/pgx_test/src/pgx_test.ml index 774d89a..4a4c04d 100644 --- a/pgx_test/src/pgx_test.ml +++ b/pgx_test/src/pgx_test.ml @@ -17,6 +17,12 @@ module Make_tests (IO : Pgx.IO) = struct type async_test = unit -> unit IO.t + let force_tests = + try + Unix.getenv "PGX_FORCE_TESTS" |> ignore; + true + with Not_found -> false + let set_to_default_db () = Unix.putenv "PGDATABASE" default_database @@ -36,7 +42,7 @@ module Make_tests (IO : Pgx.IO) = struct with_conn ?database (fun _ -> return ())) >>= function - | Error (Unix.Unix_error (Unix.ENOENT, _, _)) -> + | Error (Unix.Unix_error (Unix.ENOENT, _, _)) when not force_tests -> OUnit2.skip_if true "Could not connect to a PostgreSQL server"; assert false | Error exn ->