Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jennifersp committed Dec 28, 2023
1 parent 89c00fe commit ba6877b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 32 deletions.
52 changes: 22 additions & 30 deletions testing/bats/doltgres.bats
Original file line number Diff line number Diff line change
Expand Up @@ -3,56 +3,48 @@ load $BATS_TEST_DIRNAME/setup/common.bash

setup() {
setup_common
# dolt config was being used to create a new doltgres database
# so unset user name and email for testing
dolt config --global --unset user.name
dolt config --global --unset user.email
}

teardown() {
dolt config --global --add user.name "Bats Tests"
dolt config --global --add user.email "[email protected]"
teardown_common
}

@test 'doltgres: no args' {
export DOLTGRES_DATA_DIR=
start_sql_server_with_args "--host 0.0.0.0"
run query_server -c "\l"
[ "$status" -eq 0 ]
[[ "$output" =~ "information_schema" ]] || false
[[ "$output" =~ "doltgres" ]] || false
[[ "$output" =~ "postgres" ]] || false

@test 'doltgres: DOLTGRES_DATA_DIR set to current dir' {
[ ! -d "doltgres" ]
}

@test 'doltgres: with --data-dir' {
export DOLTGRES_DATA_DIR=
start_sql_server_with_args "--host 0.0.0.0" "--data-dir=."
run query_server -c "\l"
[ "$status" -eq 0 ]
[[ "$output" =~ "information_schema" ]] || false
[[ "$output" =~ "doltgres" ]] || false
export SQL_USER="doltgres"
start_sql_server_with_args "--host 0.0.0.0" "--user doltgres" > log.txt 2>&1

run cat log.txt
[[ ! "$output" =~ "Author identity unknown" ]] || false
[ -d "doltgres" ]
}

@test 'doltgres: with DOLTGRES_DATA_DIR' {
export DOLTGRES_DATA_DIR="$(pwd)/test"
start_sql_server_with_args "--host 0.0.0.0"
run query_server -c "\l"
[ "$status" -eq 0 ]
[[ "$output" =~ "information_schema" ]] || false
[[ "$output" =~ "doltgres" ]] || false
[[ "$output" =~ "postgres" ]] || false
}

[ -d "test/doltgres" ]
@test 'doltgres: setting both --data-dir and DOLTGRES_DATA_DIR should use --data-dir value' {
[ ! -d "doltgres" ]
}

@test 'doltgres: with both --data-dir and DOLTGRES_DATA_DIR' {
export DOLTGRES_DATA_DIR="$(pwd)/test1"
start_sql_server_with_args "--host 0.0.0.0" "--data-dir=./test2"
export SQL_USER="doltgres"
start_sql_server_with_args "--host 0.0.0.0" "--user doltgres" "--data-dir=./test" > log.txt 2>&1

run cat log.txt
[[ ! "$output" =~ "Author identity unknown" ]] || false
[ ! -d "doltgres" ]
[ -d "test/doltgres" ]

run query_server -c "\l"
[ "$status" -eq 0 ]
[[ "$output" =~ "information_schema" ]] || false
[[ "$output" =~ "doltgres" ]] || false
[[ "$output" =~ "postgres" ]] || false

[ -d "test2/doltgres" ]
[ ! -d "test1/doltgres" ]
}
4 changes: 2 additions & 2 deletions testing/bats/setup/common.bash
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ set_dolt_user() {
}

unset_dolt_user() {
doltgresql config --global --unset user.name
doltgresql config --global --unset user.email
doltgresql config --global --unset user.name
doltgresql config --global --unset user.email
}

current_dolt_user_name() {
Expand Down

0 comments on commit ba6877b

Please sign in to comment.