Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
dcda823
chore: add .worktrees/ to .gitignore
tobyhede Oct 29, 2025
8eb3c3e
test(sqlx): add comparison and inequality operator tests
tobyhede Oct 28, 2025
12cab28
test(sqlx): add <= and >= comparison operator tests
tobyhede Oct 28, 2025
289ee11
test(sqlx): add ORDER BY tests with ORE encryption
tobyhede Oct 28, 2025
2d9729f
refactor(tests): address code review suggestions
tobyhede Oct 28, 2025
23f8d3d
test(sqlx): add JSONB path operator tests (-> and ->>)
tobyhede Oct 28, 2025
5de49a8
test(sqlx): add ORE equality/inequality variant tests
tobyhede Oct 28, 2025
88e1e59
refactor(tests): improve ORE variant test coverage and consistency
tobyhede Oct 28, 2025
856ec42
test(sqlx): add containment operator tests (@> and <@)
tobyhede Oct 28, 2025
34e98d2
refactor(tests): address code review feedback for containment tests
tobyhede Oct 28, 2025
6006809
feat(test): create comprehensive test:all task combining legacy SQL a…
tobyhede Oct 28, 2025
73a4584
refactor(tasks): restructure test tasks for CI compatibility
tobyhede Oct 29, 2025
bdc2019
refactor(tasks): flatten test tasks into mise.toml with inline usage
tobyhede Oct 29, 2025
c0f77fc
fix(tasks): correct usage syntax for --postgres flag in test task
tobyhede Oct 29, 2025
c85e47f
fix(tasks): revert to using main repo's test.sh which was already wor…
tobyhede Oct 29, 2025
66328ea
fix(tasks): restore test.sh in worktree with SQLx support
tobyhede Oct 29, 2025
198ab7b
chore: ignore SQLx target directory (using sccache)
tobyhede Oct 29, 2025
ba5c140
ci: install rust
tobyhede Oct 29, 2025
b678c88
ci: making rust work
tobyhede Oct 29, 2025
53da200
fix(tests): add missing selector constants and fix operator type disa…
tobyhede Oct 29, 2025
603c4d0
test(sqlx): add config management tests (41 assertions)
tobyhede Oct 29, 2025
351845c
test(sqlx): add operator class tests (41 assertions)
tobyhede Oct 29, 2025
9f48201
fix(tests): address code review recommendations from Phase 1
tobyhede Oct 29, 2025
bcdd938
test(sqlx): add aggregate function tests (6 assertions)
tobyhede Oct 29, 2025
c764be3
test(sqlx): add constraint tests (10 assertions)
tobyhede Oct 29, 2025
1de42cf
test(sqlx): add ORE CLLW comparison tests (12 assertions)
tobyhede Oct 29, 2025
33d5c24
test(sqlx): add LIKE operator tests (10 assertions)
tobyhede Oct 29, 2025
7fa5a00
test(sqlx): add operator compare tests (63 assertions)
tobyhede Oct 29, 2025
07a12fc
test(sqlx): add specialized function tests (33 assertions)
tobyhede Oct 29, 2025
296fd2d
test(sqlx): add index comparison tests (45 assertions)
tobyhede Oct 29, 2025
083bf9a
refactor(tests): consolidate duplicate helper functions
tobyhede Oct 29, 2025
a085f81
test(sqlx): add ILIKE operator tests for case-insensitive matching
tobyhede Oct 29, 2025
fab6a39
test(sqlx): strengthen GROUP BY assertion with specific count
tobyhede Oct 29, 2025
1be11a3
test(sqlx): add FK enforcement behavior tests
tobyhede Oct 29, 2025
5cfa159
docs(tests): document inline SQL pattern rationale
tobyhede Oct 29, 2025
6e9ff4a
docs(tests): standardize assertion count comment style
tobyhede Oct 30, 2025
67497fa
docs: update SQLx test documentation with complete coverage
tobyhede Oct 30, 2025
8601b8c
docs: add comprehensive SQLx migration completion report
tobyhede Oct 30, 2025
c685a72
chore: remove comments not useful outside the context of this PR
auxesis Oct 31, 2025
8e655be
test: add lint checks for sqlx
auxesis Oct 31, 2025
532922b
chore: `cargo fmt` fixes
auxesis Oct 31, 2025
ef858d2
fix: ensure rustfmt is available in CI
auxesis Oct 31, 2025
120fe2d
ci: use setup-rust-toolchain, as it works reliably
auxesis Oct 31, 2025
ffaeefa
test: disable for now, so CI is still green
auxesis Oct 31, 2025
76f55c1
refactor: address code review feedback
tobyhede Nov 2, 2025
7c055da
ci: run on blacksmith, for 4x faster builds
auxesis Nov 5, 2025
7bf2c40
ci: remove setup-rust-toolchain, in favour of mise
auxesis Nov 5, 2025
dbb98a6
ci: upgrade mise + mise-action to latest
auxesis Nov 5, 2025
cc47986
build: explicitly install rust components
auxesis Nov 5, 2025
659e5ce
test: re-enable lints
auxesis Nov 5, 2025
6d83004
test: enable prefix output on all sub-tests
auxesis Nov 5, 2025
d78db06
ci: explicitly install Rust components, so rustfmt is available
auxesis Nov 5, 2025
65e3701
docs: state where the tests live
auxesis Nov 6, 2025
610865f
docs: remove meaningless line
auxesis Nov 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/test-eql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ defaults:
jobs:
test:
name: "Test EQL SQL components"
runs-on: ubuntu-latest-m
runs-on: blacksmith-16vcpu-ubuntu-2204

strategy:
fail-fast: false
Expand All @@ -41,9 +41,9 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: jdx/mise-action@v2
- uses: jdx/mise-action@v3
with:
version: 2025.1.6 # [default: latest] mise version to install
version: 2025.11.2 # [default: latest] mise version to install
install: true # [default: true] run `mise install`
cache: true # [default: true] cache mise using GitHub's cache

Expand All @@ -53,4 +53,6 @@ jobs:

- name: Test EQL for Postgres ${{ matrix.postgres-version }}
run: |
export active_rust_toolchain=$(rustup show active-toolchain | cut -d' ' -f1)
rustup component add --toolchain ${active_rust_toolchain} rustfmt clippy
mise run --output prefix test --postgres ${POSTGRES_VERSION}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

.DS_Store
.mise.*
.worktrees/

deps.txt
deps-ordered.txt
Expand Down Expand Up @@ -210,3 +211,6 @@ eql--*.sql

# Generated SQLx migration (built from src/, never commit)
tests/sqlx/migrations/001_install_eql.sql

# Rust build artifacts (using sccache)
tests/sqlx/target/
34 changes: 33 additions & 1 deletion mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,23 @@
# "./tests/mise.tcp.toml",
# "./tests/mise.tls.toml",
# ]

[tools]
"rust" = { version = "latest", components = "rustc,rust-std,cargo,rustfmt,rust-docs,clippy" }
"cargo:cargo-binstall" = "latest"
"cargo:sqlx-cli" = "latest"


[task_config]
includes = ["tasks", "tasks/postgres.toml", "tasks/rust.toml"]
includes = ["tasks", "tasks/postgres.toml"]
Copy link
Contributor

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

Suggested change
includes = ["tasks", "tasks/postgres.toml"]
includes = [
"tasks",
"tasks/postgres.toml"
]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto formatter says no.


[env]
POSTGRES_DB = "cipherstash"
POSTGRES_USER = "cipherstash"
POSTGRES_PASSWORD = "password"
POSTGRES_HOST = "localhost"
POSTGRES_PORT = "7432"
DATABASE_URL = "postgresql://cipherstash:password@localhost:7432/cipherstash"

[tasks."clean"]
alias = 'k'
Expand All @@ -23,3 +31,27 @@ run = """
rm -f release/cipherstash-encrypt-uninstall.sql
rm -f release/cipherstash-encrypt.sql
"""

[tasks."test:sqlx"]
description = "Run SQLx tests with hybrid migration approach"
dir = "{{config_root}}"
run = """
# Copy built SQL to SQLx migrations (EQL install is generated, not static)
echo "Updating SQLx migrations with built EQL..."
cp release/cipherstash-encrypt.sql tests/sqlx/migrations/001_install_eql.sql

# Run SQLx migrations and tests
echo "Running SQLx migrations..."
cd tests/sqlx
sqlx migrate run

echo "Running Rust tests..."
cargo test
"""

[tasks."test:sqlx:watch"]
description = "Run SQLx tests in watch mode (rebuild EQL on changes)"
dir = "{{config_root}}/tests/sqlx"
run = """
cargo watch -x test
"""
19 changes: 19 additions & 0 deletions tasks/postgres/check_container.sh
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"
#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"
32 changes: 0 additions & 32 deletions tasks/rust.toml

This file was deleted.

107 changes: 46 additions & 61 deletions tasks/test.sh
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 ""
61 changes: 61 additions & 0 deletions tasks/test/legacy.sh
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
Copy link
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Contributor

Choose a reason for hiding this comment

The 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 README.md as tests that can be run standalone.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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
9 changes: 9 additions & 0 deletions tasks/test/lint.sh
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
)
Loading