mirror of
https://github.com/dolthub/dolt.git
synced 2026-01-16 10:26:05 -06:00
Add tests for the updating prompt
This commit is contained in:
49
integration-tests/bats/sql-shell-prompt.expect
Executable file
49
integration-tests/bats/sql-shell-prompt.expect
Executable 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
|
||||
@@ -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."
|
||||
|
||||
Reference in New Issue
Block a user