Add tests for the updating prompt

This commit is contained in:
Neil Macneale IV
2024-01-04 16:42:01 -08:00
parent 0d9d7493a3
commit 790f011e92
2 changed files with 60 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
#!/usr/bin/expect
spawn dolt sql
expect {
-re "> " { send "create database mydb;\r"; }
timeout { exit 1; }
failed { exit 1; }
}
expect {
-re "> " { send "use mydb;\r"; }
timeout { exit 1; }
failed { exit 1; }
}
expect {
-re ".*mydb.*/.*main.*> " { send "create table tbl (i int);\r"; }
timeout { exit 1; }
failed { exit 1; }
}
# Dirty workspace should show in prompt as a "*" before the ">"
# (all the .* instances here are to account for ansi colors chars.
expect {
-re ".*mydb.*/.*main.*\\*.*> " { send "call dolt_commit('-Am', 'msg');\r"; }
timeout { exit 1; }
failed { exit 1; }
}
expect {
-re ".*mydb.*/.*main.*> " { send "call dolt_checkout('-b','other','HEAD');\r"; }
timeout { exit 1; }
failed { exit 1; }
}
expect {
-re ".*mydb.*/.*main.*> " { send "use mysql;\r"; }
timeout { exit 1; }
failed { exit 1; }
}
# using a non dolt db should result in a prompt without a slash. The brackets
# are required to get expect to properly parse this regex.
expect {
-re {.*mysql[^\\/]*> } { send "exit;\r"; }
timeout { exit 1; }
failed { exit 1; }
}
expect eof

View File

@@ -67,6 +67,17 @@ teardown() {
[[ "$output" =~ "+---------------------" ]] || false
}
# bats test_tags=no_lambda
@test "sql-shell: sql shell prompt updates" {
skiponwindows "Need to install expect and make this script work on windows."
# start in an empty directory
mkdir sql_shell_test
cd sql_shell_test
$BATS_TEST_DIRNAME/sql-shell-prompt.expect
}
# bats test_tags=no_lambda
@test "sql-shell: shell works after failing query" {
skiponwindows "Need to install expect and make this script work on windows."