bats: Created bats tests for replace-table and updated update-table tests

This commit is contained in:
Taylor Bantle
2019-09-19 13:34:34 -07:00
parent 05b4e4a551
commit 8304de36ce
6 changed files with 155 additions and 3 deletions

View File

@@ -0,0 +1,20 @@
{
"rows": [
{
"pk": 0,
"c1": 1,
"c2": 2,
"c3": 3,
"c4": 4,
"c5": 5
},
{
"pk": 1,
"c1": 1,
"c2": 2,
"c3": 3,
"c4": 4,
"c5": 5
}
]
}

View File

@@ -0,0 +1,36 @@
{
"rows": [
{
"id": 0,
"first name": "tim",
"last name": "sehn",
"title": "ceo",
"start date": "",
"end date": ""
},
{
"id": 1,
"first name": "aaron",
"last name": "son",
"title": "founder",
"start date": "",
"end date": ""
},
{
"id": 2,
"first name": "brian",
"last name": "hendricks",
"title": "founder",
"start date": "",
"end date": ""
},
{
"id": 3,
"first name": "matt",
"last name": "jesuele",
"title": "software engineer",
"start date": "",
"end date": ""
}
]
}

View File

@@ -0,0 +1,3 @@
id, first name, last name, position
0, "tim", "sehn", "ceo"
1, "aaron", "son", "founder"
1 id first name last name position
2 0 tim sehn ceo
3 1 aaron son founder

View File

@@ -0,0 +1,32 @@
{
"rows": [
{
"id": "0",
"first name": "tim",
"last name": "sehn",
"position": "ceo",
"children": true
},
{
"id": "1",
"first name": "aaron",
"last name": "son",
"position": "founder",
"children": true
},
{
"id": "2",
"first name": "brian",
"last name": "hendricks",
"position": "founder",
"children": true
},
{
"id": "3",
"first name": "matt",
"last name": "jesuele",
"position": "software engineer",
"children": false
}
]
}

View File

@@ -26,7 +26,59 @@ teardown() {
@test "replace table using schema with csv" {
run dolt table create -s `batshelper 1pk5col-ints.schema` test
[ "$status" -eq 0 ]
run dolt table import -u -s `batshelper 1pk5col-ints.schema` test `batshelper 1pk5col-ints.csv`
run dolt table import -r -s `batshelper 1pk5col-ints.schema` test `batshelper 1pk5col-ints.csv`
[ "$status" -eq 1 ]
[[ "$output" =~ "schema is not supported for update or replace operations" ]] || false
}
@test "replace table using json" {
run dolt table create -s `batshelper employees-sch.json` employees
[ "$status" -eq 0 ]
run dolt table import -r employees `batshelper employees-tbl.json`
[ "$status" -eq 0 ]
[[ "$output" =~ "Rows Processed: 3, Additions: 3, Modifications: 0, Had No Effect: 0" ]] || false
[[ "$output" =~ "Import completed successfully." ]] || false
}
@test "replace table using wrong json" {
run dolt table create -s `batshelper employees-sch-wrong.json` employees
[ "$status" -eq 0 ]
run dolt table import -r employees `batshelper employees-tbl.json`
[ "$status" -eq 1 ]
[[ "$output" =~ "Error replacing table" ]] || false
[[ "$output" =~ "cause: Schema from file does not match existing table schema" ]] || false
}
@test "replace table using schema with json" {
run dolt table create -s `batshelper employees-sch-wrong.json` employees
[ "$status" -eq 0 ]
run dolt table import -r -s `batshelper employees-sch.json` employees `batshelper employees-tbl.json`
[ "$status" -eq 1 ]
[[ "$output" =~ "fatal: schema is not supported for update or replace operations" ]] || false
}
@test "replace table with json when table does not exist" {
run dolt table import -r employees `batshelper employees-tbl.json`
[ "$status" -eq 1 ]
[[ "$output" =~ "The following table could not be found:" ]] || false
}
@test "replace table with existing imported data" {
run dolt table import -c -s `batshelper employees-sch.json` employees `batshelper employees-tbl.json`
[ "$status" -eq 0 ]
[[ "$output" =~ "Import completed successfully." ]] || false
run dolt table import -r employees `batshelper employees-tbl-new.json`
[ "$status" -eq 0 ]
[[ "$output" =~ "Rows Processed: 4, Additions: 4, Modifications: 0, Had No Effect: 0" ]] || false
[[ "$output" =~ "Import completed successfully." ]] || false
}
@test "replace table with existing imported data with different schema" {
run dolt table import -c -s `batshelper employees-sch.json` employees `batshelper employees-tbl.json`
[ "$status" -eq 0 ]
[[ "$output" =~ "Import completed successfully." ]] || false
run dolt table import -r employees `batshelper employees-tbl-schema-wrong.json`
[ "$status" -eq 1 ]
[[ "$output" =~ "Error replacing table" ]] || false
[[ "$output" =~ "cause: Schema from file does not match existing table schema" ]] || false
}

View File

@@ -28,7 +28,7 @@ teardown() {
[ "$status" -eq 0 ]
run dolt table import -u -s `batshelper 1pk5col-ints.schema` test `batshelper 1pk5col-ints.csv`
[ "$status" -eq 1 ]
[[ "$output" =~ "schema is not supported for update operations" ]] || false
[[ "$output" =~ "fatal: schema is not supported for update or replace operations" ]] || false
}
@test "update table using csv with newlines" {
@@ -61,7 +61,16 @@ teardown() {
[ "$status" -eq 0 ]
run dolt table import -u -s `batshelper employees-sch.json` employees `batshelper employees-tbl.json`
[ "$status" -eq 1 ]
[[ "$output" =~ "schema is not supported for update operations" ]] || false
[[ "$output" =~ "fatal: schema is not supported for update or replace operations" ]] || false
}
@test "update table with existing imported data with different schema" {
run dolt table import -c -s `batshelper employees-sch.json` employees `batshelper employees-tbl.json`
[ "$status" -eq 0 ]
[[ "$output" =~ "Import completed successfully." ]] || false
run dolt table import -u employees `batshelper employees-tbl-schema-wrong.json`
[ "$status" -eq 0 ]
[[ "$output" =~ "Rows Processed: 0, Additions: 0, Modifications: 0, Had No Effect: 0" ]] || false
}
@test "update table with json when table does not exist" {