-
-
Notifications
You must be signed in to change notification settings - Fork 530
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7463 from dolthub/james/select-into
`SELECT ... INTO OUTFILE ...` tests
- Loading branch information
Showing
5 changed files
with
117 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
#!/usr/bin/env bats | ||
load $BATS_TEST_DIRNAME/helper/common.bash | ||
|
||
setup() { | ||
setup_common | ||
dolt sql <<SQL | ||
create table t (i int, j int, k int); | ||
insert into t (i, j, k) values (1, 2, 3), (4, 5, 6), (7, 8, 9); | ||
create table emptytbl (i int, j int, k int); | ||
SQL | ||
} | ||
|
||
teardown() { | ||
assert_feature_version | ||
teardown_common | ||
} | ||
|
||
@test "sql-export: basic outfile" { | ||
run dolt sql -q "select * from t order by i, j, k into outfile './outfile.out';" | ||
[ "$status" -eq 0 ] | ||
[ -f outfile.out ] | ||
|
||
run cat outfile.out | ||
[ "$status" -eq 0 ] | ||
[[ "${#lines[@]}" = "3" ]] || false | ||
[[ "${lines[0]}" =~ "1 2 3" ]] || false | ||
[[ "${lines[1]}" =~ "4 5 6" ]] || false | ||
[[ "${lines[2]}" =~ "7 8 9" ]] || false | ||
} | ||
|
||
@test "sql-export: basic dumpfile" { | ||
run dolt sql -q "select * from t order by i, j, k limit 1 into dumpfile './dumpfile.out';" | ||
[ "$status" -eq 0 ] | ||
[ -f dumpfile.out ] | ||
|
||
run cat dumpfile.out | ||
[ "$status" -eq 0 ] | ||
[[ "${#lines[@]}" = "1" ]] || false | ||
[[ "${lines[0]}" =~ "123" ]] || false | ||
} | ||
|
||
@test "sql-export: test abs path outfile" { | ||
CURR_DIR=$(pwd) | ||
run dolt sql -q "select * from t order by i, j, k into outfile '$CURR_DIR/outfile.out';" | ||
[ "$status" -eq 0 ] | ||
[ -f outfile.out ] | ||
|
||
run cat outfile.out | ||
[ "$status" -eq 0 ] | ||
[[ "${#lines[@]}" = "3" ]] || false | ||
[[ "${lines[0]}" =~ "1 2 3" ]] || false | ||
[[ "${lines[1]}" =~ "4 5 6" ]] || false | ||
[[ "${lines[2]}" =~ "7 8 9" ]] || false | ||
} | ||
|
||
@test "sql-export: test abs path dumpfile" { | ||
CURR_DIR=$(pwd) | ||
run dolt sql -q "select * from t order by i, j, k limit 1 into dumpfile '$CURR_DIR/dumpfile.out';" | ||
[ "$status" -eq 0 ] | ||
[ -f dumpfile.out ] | ||
|
||
run cat dumpfile.out | ||
[ "$status" -eq 0 ] | ||
[[ "${#lines[@]}" = "1" ]] || false | ||
[[ "${lines[0]}" =~ "123" ]] || false | ||
} | ||
|
||
@test "sql-export: empty outfile" { | ||
run dolt sql -q "select * from emptytbl into outfile './outfile.out';" | ||
[ "$status" -eq 0 ] | ||
[ -f outfile.out ] | ||
|
||
run cat outfile.out | ||
[ "$status" -eq 0 ] | ||
[[ "${#lines[@]}" = "0" ]] || false | ||
} | ||
|
||
@test "sql-export: empty dumpfile" { | ||
run dolt sql -q "select * from emptytbl into dumpfile './dumpfile.out';" | ||
[ "$status" -eq 0 ] | ||
[ -f dumpfile.out ] | ||
|
||
run cat dumpfile.out | ||
[ "$status" -eq 0 ] | ||
[[ "${#lines[@]}" = "0" ]] || false | ||
} | ||
|
||
@test "sql-export: fails with existing files" { | ||
touch exists.out | ||
run dolt sql -q "select * from t order by i, j, k into outfile './exists.out';" | ||
[ "$status" -eq 1 ] | ||
[[ "$output" =~ "already exists" ]] || false | ||
|
||
run dolt sql -q "select * from t order by i, j, k limit 1 into dumpfile './exists.out';" | ||
[ "$status" -eq 1 ] | ||
[[ "$output" =~ "already exists" ]] || false | ||
} | ||
|
||
@test "sql-export: dumpfile fails with too many rows" { | ||
run dolt sql -q "select * from t order by i, j, k limit 3 into dumpfile './dumpfile.out';" | ||
[ "$status" -eq 1 ] | ||
[[ "$output" =~ "Result consisted of more than one row" ]] || false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters