mirror of
https://github.com/dolthub/dolt.git
synced 2025-12-29 16:13:34 -06:00
Improved testing, renamed vars
This commit is contained in:
@@ -166,7 +166,7 @@ func prettyPrintResultsWithSummary(ctx *sql.Context, resultFormat PrintResultFor
|
||||
}
|
||||
}
|
||||
|
||||
func printResultSetSummary(numRows int, numWarnings uint16, warningSummary bool, warnings string, start time.Time) error {
|
||||
func printResultSetSummary(numRows int, numWarnings uint16, warningSummary bool, warningsList string, start time.Time) error {
|
||||
|
||||
warning := ""
|
||||
if warningSummary && numWarnings > 0 {
|
||||
@@ -188,7 +188,7 @@ func printResultSetSummary(numRows int, numWarnings uint16, warningSummary bool,
|
||||
}
|
||||
|
||||
secondsSinceStart := secondsSince(start, time.Now())
|
||||
err := iohelp.WriteLine(cli.CliOut, fmt.Sprintf("%d %s in set%s (%.2f sec) %s", numRows, noun, warning, secondsSinceStart, warnings))
|
||||
err := iohelp.WriteLine(cli.CliOut, fmt.Sprintf("%d %s in set%s (%.2f sec) %s", numRows, noun, warning, secondsSinceStart, warningsList))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -84,7 +84,6 @@ type ConnectionQueryist struct {
|
||||
var _ cli.Queryist = ConnectionQueryist{}
|
||||
|
||||
func (c ConnectionQueryist) Query(ctx *sql.Context, query string) (sql.Schema, sql.RowIter, *sql.QueryFlags, error) {
|
||||
ctx.ClearWarnings()
|
||||
rows, err := c.connection.QueryContext(ctx, query)
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
@@ -95,6 +94,7 @@ func (c ConnectionQueryist) Query(ctx *sql.Context, query string) (sql.Schema, s
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
|
||||
ctx.ClearWarnings()
|
||||
warnRows, err := c.connection.QueryContext(ctx, "show warnings")
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
|
||||
@@ -37,9 +37,10 @@ teardown() {
|
||||
skiponwindows "Need to install expect and make this script work on windows."
|
||||
|
||||
run $BATS_TEST_DIRNAME/sql-warning-summary.expect
|
||||
echo "$output"
|
||||
|
||||
[ "$status" -eq 0 ]
|
||||
! [[ "$output" =~ "Warning (Code 1365): Division by 0" ]] || false
|
||||
! [[ "$output" =~ "Warning (Code 1365): Division by 0\nWarning (Code 1365): Division by 0" ]] || false
|
||||
}
|
||||
|
||||
# bats test_tags=no_lambda
|
||||
@@ -47,9 +48,9 @@ teardown() {
|
||||
skiponwindows "Need to install expect and make this script work on windows."
|
||||
|
||||
run $BATS_TEST_DIRNAME/sql-warning-detail.expect
|
||||
echo "$output"
|
||||
|
||||
[[ "$output" =~ "1 row in set, 1 warning" ]] || false
|
||||
[[ "$output" =~ "1 row in set, 2 warnings" ]] || false
|
||||
[ "$status" -eq 0 ]
|
||||
! [[ "$output" =~ "1 row in set, 3 warnings" ]] || false
|
||||
|
||||
}
|
||||
|
||||
@@ -7,34 +7,15 @@ source "$env(BATS_CWD)/helper/common_expect_functions.tcl"
|
||||
|
||||
spawn dolt sql
|
||||
|
||||
expect {
|
||||
-re "dolt-repo-.*> " {send "select 1/0;\r"; }
|
||||
timeout { exit 1; }
|
||||
failed { exit 1; }
|
||||
}
|
||||
expect_with_defaults {dolt-repo-.*} { send "select 1/0;\r"; }
|
||||
|
||||
expect {
|
||||
-re "dolt-repo-.*> " { send "select 1/0, 1/0;\r"; }
|
||||
timeout { exit 1; }
|
||||
failed { exit 1; }
|
||||
}
|
||||
expect_with_defaults_2 {1 row in set, 1 warning} {dolt-repo-.*} { send "select 1/0, 1/0;\r"; }
|
||||
|
||||
expect {
|
||||
-re "dolt-repo-.*> " { send "set sql_warnings = 0;\r"; }
|
||||
timeout { exit 1; }
|
||||
failed { exit 1; }
|
||||
}
|
||||
expect_with_defaults_2 {1 row in set, 2 warnings} {dolt-repo-.*} { send "set sql_warnings = 0;\r"; }
|
||||
|
||||
expect {
|
||||
-re "dolt-repo-.*> " { send "select 1/0, 1/0, 1/0;\r"; }
|
||||
timeout { exit 1; }
|
||||
failed { exit 1; }
|
||||
}
|
||||
expect_with_defaults {dolt-repo-.*} { send "select 1/0, 1/0, 1/0;\r"; }
|
||||
|
||||
expect {
|
||||
-re "dolt-repo-.*> " { send "exit;\r"; }
|
||||
timeout { exit 1; }
|
||||
failed { exit 1; }
|
||||
}
|
||||
expect_with_defaults {dolt-repo-.*} { send "exit;\r"; }
|
||||
|
||||
expect eof
|
||||
expect eof
|
||||
exit
|
||||
@@ -7,12 +7,13 @@ source "$env(BATS_CWD)/helper/common_expect_functions.tcl"
|
||||
|
||||
spawn dolt sql
|
||||
|
||||
expect_with_defaults {dolt-repo-.*>} { send "explain select * from t;"; }
|
||||
expect_with_defaults {dolt-repo-.*>} { send "select 1/0;\r"; }
|
||||
|
||||
expect_with_defaults_2 {EXPLAIN output is currently a placeholder} {dolt-repo-.*>} { send "\\w\r"; }
|
||||
expect_with_defaults_2 {Warning \(Code 1365\): Division by 0} {dolt-repo-.*>} { send "\\w\r"; }
|
||||
|
||||
expect_with_defaults_2 {Show warnings disabled} {dolt-repo-.*>} { send "select 1/0;"; }
|
||||
expect_with_defaults_2 {Show warnings disabled} {dolt-repo-.*>} { send "select 1/0,1/0;\r"; }
|
||||
|
||||
expect_with_defaults {dolt-repo-.*>} { send "exit;"; }
|
||||
expect_with_defaults {dolt-repo-.*>} { send "quit;\r"; }
|
||||
|
||||
expect eof
|
||||
expect eof
|
||||
exit
|
||||
Reference in New Issue
Block a user