#!/usr/bin/env bats # Backward / forward compatibility tests for doltgresql. # # Each test starts a fresh doltgres server against a copy of the pre-created repo # (REPO_DIR) and verifies that the binary under test can correctly read and write # the data created by the other version. # # Environment variables consumed by this file: # REPO_DIR — path to the data directory created by setup_repo.sh # DOLTGRES_TEST_BIN — doltgres binary to use (default: doltgres from PATH) load $BATS_TEST_DIRNAME/helper/common.bash BATS_REPO="" setup() { BATS_REPO="$BATS_TMPDIR/compat-repo-$$-$RANDOM" copy_repo "$REPO_DIR" "$BATS_REPO" start_doltgres "${DOLTGRES_TEST_BIN:-doltgres}" "$BATS_REPO" "$BATS_REPO/server.log" } teardown() { stop_doltgres rm -rf "$BATS_REPO" } # --------------------------------------------------------------------------- # Sanity / version checks # --------------------------------------------------------------------------- @test "compatibility: server is accessible" { run sql -c "SELECT 1;" [ "$status" -eq 0 ] } @test "compatibility: dolt_version returns a version string" { run sql -c "SELECT dolt_version();" [ "$status" -eq 0 ] [[ "$output" =~ [0-9]+\.[0-9]+\.[0-9]+ ]] || false } # --------------------------------------------------------------------------- # Branch enumeration # --------------------------------------------------------------------------- @test "compatibility: expected branches exist" { run sql_csv -c "SELECT name FROM dolt_branches ORDER BY name;" [ "$status" -eq 0 ] [[ "$output" =~ "check_merge" ]] || false [[ "$output" =~ "init" ]] || false [[ "$output" =~ "main" ]] || false [[ "$output" =~ "other" ]] || false } # --------------------------------------------------------------------------- # Working set is clean on main # --------------------------------------------------------------------------- @test "compatibility: working set is clean on main" { run sql -c "SELECT * FROM dolt_status;" [ "$status" -eq 0 ] [[ "$output" =~ "(0 rows)" ]] || false } # --------------------------------------------------------------------------- # Schema on branch init (original schema before alterations) # --------------------------------------------------------------------------- @test "compatibility: schema on branch init has original abc columns" { run sql <