-
Notifications
You must be signed in to change notification settings - Fork 0
SQLx Test Suite - Consolidated Implementation #147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
dcda823
8eb3c3e
12cab28
289ee11
2d9729f
23f8d3d
5de49a8
88e1e59
856ec42
34e98d2
6006809
73a4584
bdc2019
c0f77fc
c85e47f
66328ea
198ab7b
ba5c140
b678c88
53da200
603c4d0
351845c
9f48201
bcdd938
c764be3
1de42cf
33d5c24
7fa5a00
07a12fc
296fd2d
083bf9a
a085f81
fab6a39
1be11a3
5cfa159
6e9ff4a
67497fa
8601b8c
c685a72
8e655be
532922b
ef858d2
120fe2d
ffaeefa
76f55c1
7c055da
7bf2c40
dbb98a6
cc47986
659e5ce
6d83004
d78db06
65e3701
610865f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| #!/usr/bin/env bash | ||
| #MISE description="Check if PostgreSQL container is running" | ||
tobyhede marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| #USAGE flag "--postgres <version>" help="PostgreSQL version to check" default="17" { | ||
| #USAGE choices "14" "15" "16" "17" | ||
| #USAGE } | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| POSTGRES_VERSION=${usage_postgres} | ||
| container_name=postgres-${POSTGRES_VERSION} | ||
|
|
||
| containers=$(docker ps --filter "name=^${container_name}$" --quiet) | ||
| if [ -z "${containers}" ]; then | ||
| echo "error: Docker container for PostgreSQL is not running" | ||
| echo "error: Try running 'mise run postgres:up postgres-${POSTGRES_VERSION}' to start the container" | ||
| exit 65 | ||
| fi | ||
|
|
||
| echo "✓ PostgreSQL ${POSTGRES_VERSION} container is running" | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,71 +1,56 @@ | ||
| #!/usr/bin/env bash | ||
| #MISE description="Build, reset and run tests" | ||
| #MISE description="Run all tests (legacy SQL + SQLx Rust)" | ||
| #USAGE flag "--test <test>" help="Test to run" default="false" | ||
| #USAGE flag "--postgres <version>" help="Run tests for specified Postgres version" default="17" { | ||
| #USAGE flag "--postgres <version>" help="PostgreSQL version to test against" default="17" { | ||
| #USAGE choices "14" "15" "16" "17" | ||
| #USAGE } | ||
|
|
||
| #!/bin/bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| POSTGRES_VERSION=${usage_postgres} | ||
|
|
||
| connection_url=postgresql://${POSTGRES_USER:-$USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB} | ||
| container_name=postgres-${POSTGRES_VERSION} | ||
|
|
||
| fail_if_postgres_not_running () { | ||
| containers=$(docker ps --filter "name=^${container_name}$" --quiet) | ||
| if [ -z "${containers}" ]; then | ||
| echo "error: Docker container for PostgreSQL is not running" | ||
| echo "error: Try running 'mise run postgres:up ${container_name}' to start the container" | ||
| exit 65 | ||
| fi | ||
| } | ||
|
|
||
| run_test () { | ||
| echo | ||
| echo '###############################################' | ||
| echo "# Running Test: ${1}" | ||
| echo '###############################################' | ||
| echo | ||
|
|
||
| cat $1 | docker exec -i ${container_name} psql --variable ON_ERROR_STOP=1 $connection_url -f- | ||
| } | ||
|
|
||
| # setup | ||
| fail_if_postgres_not_running | ||
| mise run build --force | ||
| mise run reset --force --postgres ${POSTGRES_VERSION} | ||
|
|
||
| echo | ||
| echo '###############################################' | ||
| echo '# Installing release/cipherstash-encrypt.sql' | ||
| echo '###############################################' | ||
| echo | ||
|
|
||
| # Install | ||
| cat release/cipherstash-encrypt.sql | docker exec -i ${container_name} psql ${connection_url} -f- | ||
|
|
||
|
|
||
| cat tests/test_helpers.sql | docker exec -i ${container_name} psql ${connection_url} -f- | ||
| cat tests/ore.sql | docker exec -i ${container_name} psql ${connection_url} -f- | ||
| cat tests/ste_vec.sql | docker exec -i ${container_name} psql ${connection_url} -f- | ||
|
|
||
|
|
||
| if [ $usage_test = "false" ]; then | ||
| find src -type f -path "*_test.sql" | while read -r sql_file; do | ||
| echo $sql_file | ||
| run_test $sql_file | ||
| done | ||
| else | ||
| find src -type f -path "*$usage_test*" | while read -r sql_file; do | ||
| run_test $sql_file | ||
| done | ||
| fi | ||
|
|
||
| echo | ||
| echo '###############################################' | ||
| echo "# ✅ALL TESTS PASSED " | ||
| echo '###############################################' | ||
| echo | ||
| echo "==========================================" | ||
| echo "Running Complete EQL Test Suite" | ||
| echo "PostgreSQL Version: $POSTGRES_VERSION" | ||
| echo "==========================================" | ||
| echo "" | ||
|
|
||
| # Check PostgreSQL is running | ||
| "$(dirname "$0")/postgres/check_container.sh" ${POSTGRES_VERSION} | ||
|
|
||
| # Build first | ||
| echo "Building EQL..." | ||
| mise run --output prefix build --force | ||
|
|
||
| # Run lints on sqlx tests | ||
| echo "" | ||
| echo "==============================================" | ||
| echo "1/3: Running linting checks on SQLx Rust tests" | ||
| echo "==============================================" | ||
| mise run --output prefix test:lint | ||
|
|
||
| # Run legacy SQL tests | ||
| echo "" | ||
| echo "==============================================" | ||
| echo "2/3: Running Legacy SQL Tests" | ||
| echo "==============================================" | ||
| mise run --output prefix test:legacy --postgres ${POSTGRES_VERSION} | ||
|
|
||
| # Run SQLx Rust tests | ||
| echo "" | ||
| echo "==============================================" | ||
| echo "3/3: Running SQLx Rust Tests" | ||
| echo "==============================================" | ||
| mise run --output prefix test:sqlx | ||
|
|
||
| echo "" | ||
| echo "==============================================" | ||
| echo "✅ ALL TESTS PASSED" | ||
| echo "==============================================" | ||
| echo "" | ||
| echo "Summary:" | ||
| echo " ✓ SQLx Rust lint checks" | ||
| echo " ✓ Legacy SQL tests" | ||
| echo " ✓ SQLx Rust tests" | ||
| echo "" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| #!/usr/bin/env bash | ||
| #MISE description="Run legacy SQL tests (inline test files)" | ||
| #USAGE flag "--test <test>" help="Specific test file pattern to run" default="false" | ||
| #USAGE flag "--postgres <version>" help="PostgreSQL version to test against" default="17" { | ||
| #USAGE choices "14" "15" "16" "17" | ||
| #USAGE } | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| POSTGRES_VERSION=${usage_postgres} | ||
|
|
||
| connection_url=postgresql://${POSTGRES_USER:-$USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB} | ||
| container_name=postgres-${POSTGRES_VERSION} | ||
|
|
||
| # Check postgres is running (script will exit if not) | ||
| source "$(dirname "$0")/../postgres/check_container.sh" ${POSTGRES_VERSION} | ||
|
|
||
| run_test () { | ||
| echo | ||
| echo '###############################################' | ||
| echo "# Running Test: ${1}" | ||
| echo '###############################################' | ||
| echo | ||
|
|
||
| cat $1 | docker exec -i ${container_name} psql --variable ON_ERROR_STOP=1 $connection_url -f- | ||
| } | ||
|
|
||
| # Reset database | ||
| mise run reset --force --postgres ${POSTGRES_VERSION} | ||
|
|
||
| echo | ||
| echo '###############################################' | ||
| echo '# Installing release/cipherstash-encrypt.sql' | ||
| echo '###############################################' | ||
| echo | ||
|
|
||
| # Install | ||
| cat release/cipherstash-encrypt.sql | docker exec -i ${container_name} psql ${connection_url} -f- | ||
|
|
||
|
|
||
| cat tests/test_helpers.sql | docker exec -i ${container_name} psql ${connection_url} -f- | ||
| cat tests/ore.sql | docker exec -i ${container_name} psql ${connection_url} -f- | ||
| cat tests/ste_vec.sql | docker exec -i ${container_name} psql ${connection_url} -f- | ||
|
Comment on lines
+42
to
+43
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the deal with these tests? Is there a reason they haven't been migrated to sqlx? Doesn't this contradict what was stated earlier about 103% of the test being migrated?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And if they do need to be kept as SQL, they need to be documented in
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have not removed the old tests (yet) Will document - my intention is to keep them around for a while to ensure coverage until we are 103% confident |
||
|
|
||
|
|
||
| if [ $usage_test = "false" ]; then | ||
| find src -type f -path "*_test.sql" | while read -r sql_file; do | ||
| echo $sql_file | ||
| run_test $sql_file | ||
| done | ||
| else | ||
| find src -type f -path "*$usage_test*" | while read -r sql_file; do | ||
| run_test $sql_file | ||
| done | ||
| fi | ||
|
|
||
| echo | ||
| echo '###############################################' | ||
| echo "# ✅ALL TESTS PASSED " | ||
| echo '###############################################' | ||
| echo | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| #!/usr/bin/env bash | ||
| #MISE description="Run lint tests" | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| ( | ||
| cd tests/sqlx/ | ||
| cargo fmt --check -- --files-with-diff | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chore: line per task, to make cleaner diffs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Auto formatter says no.