#!/usr/bin/env bats load $BATS_TEST_DIRNAME/helpers.bash # PostgreSQL client tests are set up to test Doltgres as a PostgreSQL server and # standard PostgreSQL Clients in a wide array of languages. setup() { setup_doltgres_repo query_server -c "CREATE TABLE IF NOT EXISTS test_table(pk int)" -t query_server -c "DELETE FROM test_table" -t query_server -c "INSERT INTO test_table VALUES (1)" -t } teardown() { cd .. teardown_doltgres_repo } @test "postgres-connector-java client" { javac $BATS_TEST_DIRNAME/java/PostgresTest.java java -cp $BATS_TEST_DIRNAME/java:$BATS_TEST_DIRNAME/java/postgresql-42.7.3.jar PostgresTest $USER $PORT } @test "r2dbc-postgresql client" { java -jar /build/bin/r2dbc/r2dbc-test.jar $USER $PORT } @test "node postgres client" { node $BATS_TEST_DIRNAME/node/index.js $USER $PORT } @test "knex node postgres client" { DOLTGRES_VERSION=$( doltgres --version | sed -nre 's/^[^0-9]*(([0-9]+\.)*[0-9]+).*/\1/p' ) echo $DOLTGRES_VERSION node $BATS_TEST_DIRNAME/node/knex.js $USER $PORT $DOLTGRES_VERSION } @test "node postgres client, workbench stability" { skip "Passes locally, fails on CI, investigating" DOLTGRES_VERSION=$( doltgres --version | sed -nre 's/^[^0-9]*(([0-9]+\.)*[0-9]+).*/\1/p' ) echo $DOLTGRES_VERSION node $BATS_TEST_DIRNAME/node/workbench.js $USER $PORT $DOLTGRES_VERSION $BATS_TEST_DIRNAME/node/testdata } @test "perl DBI:Pg client" { perl $BATS_TEST_DIRNAME/perl/postgres-test.pl $USER $PORT } @test "ruby pg test" { ruby $BATS_TEST_DIRNAME/ruby/pg-test.rb $USER $PORT } @test "ruby Sequel client" { ruby $BATS_TEST_DIRNAME/ruby/sequel-test.rb $USER $PORT } @test "ruby ActiveRecord client" { ruby $BATS_TEST_DIRNAME/ruby/activerecord-test.rb $USER $PORT } @test "php pg_connect client" { cd $BATS_TEST_DIRNAME/php php pg_connect_test.php $USER $PORT } @test "php pdo pgsql client" { cd $BATS_TEST_DIRNAME/php php pdo_connector_test.php $USER $PORT } @test "c postgres: libpq connector" { (cd $BATS_TEST_DIRNAME/c; make clean; make) $BATS_TEST_DIRNAME/c/postgres-c-connector-test $USER $PORT } @test "c++ libpqxx client" { cd $BATS_TEST_DIRNAME/cpp make ./libpqxx-test $USER $PORT } @test "psqlODBC client" { cd $BATS_TEST_DIRNAME/odbc make ./psqlodbc-test $USER $PORT } @test "python postgres: psycopg2 client" { cd $BATS_TEST_DIRNAME/python python3 psycopg2_test.py $USER $PORT } @test "python postgres: sqlalcchemy client" { cd $BATS_TEST_DIRNAME/python python3 sqlalchemy-test.py $USER $PORT } @test "Drizzle ORM smoke test" { # the schema should be empty query_server -c "DROP TABLE IF EXISTS test_table" -t cd $BATS_TEST_DIRNAME/drizzle # Construct the string and append it to the .env file touch .env echo "DATABASE_URL=postgres://$USER:password@localhost:$PORT/postgres" >> .env npm i drizzle-orm pg dotenv npm i -D drizzle-kit tsx @types/pg npx drizzle-kit push # we can check if 'components table was created' query_server -c "SELECT * FROM users" -t run query_server -c "SELECT * FROM users" -t [ "$status" -eq 0 ] # this inserts and updates row and check its updated result npx tsx src/index.ts } @test "R RPostgres client" { Rscript $BATS_TEST_DIRNAME/r/rpostgres-test.r $USER $PORT } @test "R RPostgreSQL client" { Rscript $BATS_TEST_DIRNAME/r/rpostgresql-test.r $USER $PORT } @test "rust sqlx" { /build/bin/rust/sqlx_exists_demo $USER $PORT } @test "go pgx client" { /build/bin/go/pgx-test $USER $PORT } @test "go lib/pq client" { /build/bin/go/libpq-test $USER $PORT } @test "dotnet Npgsql client" { /build/bin/dotnet/npgsql-test $USER $PORT } @test "elixir postgrex client" { skip "fails from https://github.com/dolthub/doltgresql/issues/2859" /build/bin/elixir/postgrex-test $USER $PORT } @test "swift postgresnio client" { /build/bin/swift/postgresnio-test $USER $PORT } @test "libaprutil apr_dbd client" { (cd $BATS_TEST_DIRNAME/c; make) $BATS_TEST_DIRNAME/c/libaprutil-test $USER $PORT } @test "libdbi pgsql client" { (cd $BATS_TEST_DIRNAME/c; make) $BATS_TEST_DIRNAME/c/libdbi-test $USER $PORT }