Skip to content

Commit

Permalink
Fix bats
Browse files Browse the repository at this point in the history
  • Loading branch information
fanyang01 committed Dec 19, 2024
1 parent d35d82f commit e5cda00
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions test/bats/postgres/cli.bats
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,15 @@ load helper

# `DISCARD ALL` should clear all temp tables
@test "discard_all_clears_temp_tables" {
# Create temp table and insert data
psql_exec "CREATE TEMP TABLE tt (id int);"
psql_exec "INSERT INTO tt VALUES (1), (2);"

# Verify data exists
run psql_exec "SELECT COUNT(*) FROM tt;"
[ "$status" -eq 0 ]
[ "${lines[0]}" = "2" ]
# Run all SQL statements in a single session
run psql_exec_stdin <<-EOF
CREATE TEMP TABLE tt (id int);
INSERT INTO tt VALUES (1), (2);
SELECT COUNT(*) FROM tt;
DISCARD ALL;
SELECT COUNT(*) FROM tt;
EOF

# Run DISCARD ALL
psql_exec "DISCARD ALL;"

# Verify temp table no longer exists
run psql_exec "SELECT COUNT(*) FROM tt;"
[ "$status" -eq 1 ]
[[ "${output}" == *"Table with name tt does not exist"* ]]
}

0 comments on commit e5cda00

Please sign in to comment.