From a8ee8c30dc06ee27d1f98e443f9ac6a88ab7d270 Mon Sep 17 00:00:00 2001 From: Daylon Wilkins Date: Thu, 23 Jan 2020 10:59:15 -0800 Subject: [PATCH] Removed Windows carriage-return and trailing whitespace from bats tests --- bats/1pk5col-ints.bats | 12 +- bats/1pk5col-strings.bats | 8 +- bats/2pk5cols-ints.bats | 2 +- bats/blame.bats | 2 +- bats/config.bats | 2 +- bats/conflict-detection.bats | 6 +- bats/create-tables.bats | 6 +- bats/diff.bats | 8 +- bats/docs.bats | 40 ++-- bats/empty-repo.bats | 430 +++++++++++++++++------------------ bats/multiple-tables.bats | 8 +- bats/no-repo.bats | 424 +++++++++++++++++----------------- bats/remotes.bats | 12 +- bats/schema-changes.bats | 2 +- bats/schema-import.bats | 2 +- bats/send_metrics.bats | 4 +- bats/update-tables.bats | 214 ++++++++--------- 17 files changed, 591 insertions(+), 591 deletions(-) diff --git a/bats/1pk5col-ints.bats b/bats/1pk5col-ints.bats index 7c922533d7a..fe97b644a5d 100755 --- a/bats/1pk5col-ints.bats +++ b/bats/1pk5col-ints.bats @@ -22,7 +22,7 @@ teardown() { # Create a single primary key table and do stuff @test "create a table with a schema file and examine repo" { - # Remove the docs, because they will show up in the diff below and break the lines[x] assertions. + # Remove the docs, because they will show up in the diff below and break the lines[x] assertions. rm LICENSE.md rm README.md run dolt ls @@ -49,7 +49,7 @@ teardown() { [ "$status" -eq 0 ] [[ "$output" =~ "Changes to be committed" ]] [[ "$output" =~ "new table:" ]] || false - run dolt reset test + run dolt reset test [ "$status" -eq 0 ] [ "$output" = "" ] run dolt status @@ -75,7 +75,7 @@ teardown() { @test "dolt log with -n specified" { dolt add test dolt commit -m "first commit" - run dolt log + run dolt log [ "$status" -eq "0" ] [[ "$output" =~ "first commit" ]] || false [[ "$output" =~ "Initialize data repository" ]] || false @@ -375,7 +375,7 @@ if rows[2] != "9,8,7,6,5,4".split(","): dolt sql -q "insert into test values (0, 1, 2, 3, 4, 5)" dolt add test dolt commit -m "added test row" - run dolt branch -d test-branch + run dolt branch -d test-branch [ "$status" -ne 0 ] [ "$output" = "error: Cannot delete checked out branch 'test-branch'" ] dolt checkout master @@ -426,7 +426,7 @@ if rows[2] != "9,8,7,6,5,4".split(","): @test "generate a merge conflict and try to roll back using dolt merge --abort" { # L&R must be removed (or added and committed) in order to test merge - rm "LICENSE.md" + rm "LICENSE.md" rm "README.md" dolt add test dolt commit -m "added test table" @@ -626,7 +626,7 @@ if rows[2] != "9,8,7,6,5,4".split(","): [ "$status" -eq 0 ] [[ "$output" =~ "" ]] || false [ "$output" = "$doltsqloutput" ] - # Make sure we don't get a table with no spaces because that bug was + # Make sure we don't get a table with no spaces because that bug was # generated when making changes to NULL printing [[ ! "$output" =~ "|||||" ]] || false } diff --git a/bats/1pk5col-strings.bats b/bats/1pk5col-strings.bats index fdc9418725d..497e2e55728 100755 --- a/bats/1pk5col-strings.bats +++ b/bats/1pk5col-strings.bats @@ -19,7 +19,7 @@ SQL teardown() { teardown_common } - + @test "export a table with a string with commas to csv" { run dolt sql -q "insert into test values ('tim', 'is', 'super', 'duper', 'rad', 'a,b,c,d,e')" [ "$status" -eq 0 ] @@ -57,7 +57,7 @@ teardown() { run dolt sql -q "select * from test" [ "$status" -eq 0 ] # All row counts are offset by 4 to account for table printing - [ "${#lines[@]}" -eq 7 ] + [ "${#lines[@]}" -eq 7 ] run dolt sql -q "select * from test where pk='tim'" [ "$status" -eq 0 ] [ "${#lines[@]}" -eq 5 ] @@ -102,7 +102,7 @@ teardown() { dolt sql -q "insert into test (pk) values ('brian')" run dolt sql -q "select * from test" [ "$status" -eq 0 ] - # select orders by primary key right now so aaron, brian, tim + # select orders by primary key right now so aaron, brian, tim [[ "${lines[4]}" =~ "" ]] || false [[ ! "${lines[5]}" =~ "" ]] || false doltselectoutput=$output @@ -110,7 +110,7 @@ teardown() { [ "$status" -eq 0 ] [[ "$output" =~ "" ]] || false [ "$output" = "$doltselectoutput" ] - # Make sure we don't get a table with no spaces because that bug was + # Make sure we don't get a table with no spaces because that bug was # generated when making changes to NULL printing [[ ! "$output" =~ "|||||" ]] || false } diff --git a/bats/2pk5cols-ints.bats b/bats/2pk5cols-ints.bats index bfa141da6cd..c47e6559162 100755 --- a/bats/2pk5cols-ints.bats +++ b/bats/2pk5cols-ints.bats @@ -22,7 +22,7 @@ teardown() { } @test "create a table with a schema file and examine repo" { - # Remove the docs, because they will show up in the diff below and break the lines[x] assertions. + # Remove the docs, because they will show up in the diff below and break the lines[x] assertions. rm LICENSE.md rm README.md run dolt ls diff --git a/bats/blame.bats b/bats/blame.bats index 5e2b5169f48..bb13c9c21f6 100644 --- a/bats/blame.bats +++ b/bats/blame.bats @@ -12,7 +12,7 @@ teardown() { setup_repository() { stash_current_dolt_user - + set_dolt_user "Thomas Foolery", "bats-1@email.fake" dolt sql < LICENSE.md dolt sql < README.md @@ -243,7 +243,7 @@ SQL [[ "$output" =~ "Changes not staged for commit:" ]] || false [[ "$output" =~ ([[:space:]]*modified:[[:space:]]*README.md) ]] || false run cat README.md - [[ "$output" =~ "~new-text~" ]] + [[ "$output" =~ "~new-text~" ]] } @test "dolt reset --soft should remove docs from staging area" { @@ -257,8 +257,8 @@ SQL [[ "$output" =~ "Untracked files:" ]] || false [[ "$output" =~ ([[:space:]]*new doc:[[:space:]]*LICENSE.md) ]] || false [[ "$output" =~ ([[:space:]]*new doc:[[:space:]]*README.md) ]] || false - - + + dolt add . dolt commit -m "initial doc commit" echo ~new-text~ > README.md @@ -269,7 +269,7 @@ SQL [[ "$output" =~ "Changes not staged for commit:" ]] || false [[ "$output" =~ ([[:space:]]*modified:[[:space:]]*README.md) ]] || false run cat README.md - [[ "$output" =~ "~new-text~" ]] + [[ "$output" =~ "~new-text~" ]] } @test "dolt reset should remove docs from staging area" { @@ -294,22 +294,22 @@ SQL [[ "$output" =~ "Changes not staged for commit:" ]] || false [[ "$output" =~ ([[:space:]]*modified:[[:space:]]*README.md) ]] || false run cat README.md - [[ "$output" =~ "~new-text~" ]] + [[ "$output" =~ "~new-text~" ]] } @test "dolt reset should remove doc from staging area" { dolt add LICENSE.md - + run dolt reset dolt_docs [ "$status" -eq 1 ] [[ "$output" =~ "'dolt_docs' is not a valid table name" ]] || false - + dolt reset LICENSE.md run dolt status [ "$status" -eq 0 ] [[ "$output" =~ "Untracked files:" ]] || false [[ "$output" =~ ([[:space:]]*new doc:[[:space:]]*LICENSE.md) ]] || false - + dolt add . run dolt reset LICENSE.md invalid [ "$status" -eq 1 ] @@ -380,8 +380,8 @@ SQL [[ "$output" =~ "this is my license" ]] || false run cat README.md [[ "$output" =~ "This is a repository level README" ]] || false - - + + echo "testing-modified-doc" > LICENSE.md dolt checkout LICENSE.md run cat LICENSE.md @@ -413,7 +413,7 @@ SQL run dolt status [ "$status" -eq 0 ] [[ ! "$output" =~ "README.md" ]] || false - run ls + run ls [[ ! "$output" =~ "README.md" ]] || false [[ "$output" =~ "LICENSE.md" ]] || false } @@ -436,7 +436,7 @@ SQL [[ ! "$output" =~ "LICENSE.md" ]] || false [[ ! "$output" =~ "test1" ]] || false [[ "$output" =~ "README.md" ]] || false - run ls + run ls [[ ! "$output" =~ "LICENSE.md" ]] || false [[ "$output" =~ "README.md" ]] || false run cat README.md @@ -642,7 +642,7 @@ SQL [[ ! "$output" =~ "dolt_docs" ]] || false dolt add . dolt commit -m "initial doc commits" - + run dolt sql -q "show tables" [ "$status" -eq 0 ] [[ ! "$output" =~ "dolt_docs" ]] || false @@ -732,7 +732,7 @@ SQL [[ $output =~ "test-b-again branch" ]] || false dolt add . dolt commit -m "merge test-b-again with fixed conflicts" - + # A merge with auto-resolved conflicts updates the working root. The docs should match the new working root. dolt checkout test-b-again echo test-b-one-more-time > README.md diff --git a/bats/empty-repo.bats b/bats/empty-repo.bats index 77184b0835d..7e6eaadd905 100755 --- a/bats/empty-repo.bats +++ b/bats/empty-repo.bats @@ -1,215 +1,215 @@ -#!/usr/bin/env bats -load $BATS_TEST_DIRNAME/helper/common.bash - -setup() { - setup_common -} - -teardown() { - teardown_common -} - -# Tests on an empty dolt repository -@test "dolt init on an already initialized repository" { - run dolt init - [ "$status" -ne 0 ] - [ "$output" = "This directory has already been initialized." ] -} - -@test "dolt status on a new repository" { - run dolt status - [ "$status" -eq 0 ] - [ "${lines[0]}" = "On branch master" ] - [ "${lines[1]}" = "Untracked files:" ] - [ "${lines[2]}" = ' (use "dolt add " to include in what will be committed)' ] - [[ "${lines[3]}" =~ ([[:space:]]*new doc:[[:space:]]*LICENSE.md) ]] || false - [[ "${lines[4]}" =~ ([[:space:]]*new doc:[[:space:]]*README.md) ]] || false - run ls - [ "${lines[0]}" = "LICENSE.md" ] - [ "${lines[1]}" = "README.md" ] - # L&R must be removed (or added and committed) for `nothing to commit` message to display - run rm "LICENSE.md" - run rm "README.md" - run dolt status - [ "$status" -eq 0 ] - [ "${lines[0]}" = "On branch master" ] - [ "${lines[1]}" = "nothing to commit, working tree clean" ] -} - -@test "dolt ls in a new repository" { - run dolt ls - [ "$status" -eq 0 ] - [ "$output" = "No tables in working set" ] -} - -@test "dolt branch in a new repository" { - run dolt branch - [ "$status" -eq 0 ] - # I can't seem to get this to match "* master" so I made a regex instead - # [ "$output" = "* master" ] - [[ "$output" =~ "* master" ]] || false -} - -@test "dolt log in a new repository" { - run dolt log - [ "$status" -eq 0 ] - [[ "$output" =~ "commit " ]] || false - [[ "$output" =~ "Initialize data repository" ]] || false -} - -@test "dolt add . in new repository" { - run dolt add . - [ "$status" -eq 0 ] - [ "$output" = "" ] -} - -@test "dolt reset in new repository" { - run dolt reset - [ "$status" -eq 0 ] - [ "$output" = "" ] -} - -@test "dolt diff in new repository" { - run dolt diff - [ "$status" -eq 0 ] - [[ "$output" =~ "diff --dolt a/LICENSE.md b/LICENSE.md" ]] || false - [[ "$output" =~ "diff --dolt a/README.md b/README.md" ]] || false - [[ "$output" =~ "added doc" ]] || false -} - -@test "dolt commit with nothing added" { - # L&R must be removed (or added and committed) in order to test `no changes added to commit` message - rm "LICENSE.md" - rm "README.md" - run dolt commit -m "commit" - [ "$status" -eq 1 ] - [ "$output" = 'no changes added to commit (use "dolt add")' ] -} - -@test "dolt commit --allow-empty with nothing added" { - run dolt commit -m "distinctively-named commit" --allow-empty - [ "$status" -eq 0 ] - run dolt log - [[ "$output" =~ "distinctively-named commit" ]] || false -} - -@test "dolt sql in a new repository" { - run dolt sql -q "select * from test" - [ "$status" -eq 1 ] - [[ "$output" = "table not found: test" ]] || false -} - -@test "invalid sql in a new repository" { - run dolt sql -q "foo bar" - [ "$status" -eq 1 ] - [[ "$output" =~ "Error parsing SQL" ]] || false -} - -@test "dolt schema show in new repository" { - run dolt schema show - [ "$status" -eq 1 ] - [[ "$output" =~ "usage" ]] || false -} - -@test "dolt table select in new repository" { - run dolt sql -q "select * from test" - [ "$status" -ne 0 ] -} - -@test "dolt table import in a new repository" { - run dolt table import - [ "$status" -ne 0 ] - [[ "${lines[0]}" =~ "usage" ]] || false -} - -@test "dolt table export in a new repository" { - run dolt table export - [ "$status" -ne 0 ] - [[ "${lines[0]}" =~ "usage" ]] || false -} - -@test "dolt table rm in a new repository" { - run dolt table rm - [ "$status" -ne 0 ] - [[ "${lines[0]}" =~ "usage" ]] || false -} - -@test "dolt table cp in a new repository" { - run dolt table cp - [ "$status" -ne 0 ] - [[ "${lines[0]}" =~ "usage" ]] || false -} - -@test "dolt checkout master on master" { - run dolt checkout master - [ "$status" -eq 1 ] - [ "$output" = "Already on branch 'master'" ] -} - -@test "dolt checkout non-existant branch" { - run dolt checkout foo - [ "$status" -ne 0 ] - [ "$output" = "error: could not find foo" ] -} - -@test "create and checkout a branch" { - run dolt branch test - [ "$status" -eq 0 ] - [ "$output" = "" ] - run dolt checkout test - [ "$status" -eq 0 ] - [ "$output" = "Switched to branch 'test'" ] - run dolt branch - [ "$status" -eq 0 ] - [[ "$output" =~ "* test" ]] || false -} - -@test "create and checkout a branch with dolt checkout -b" { - run dolt checkout -b test - [ "$status" -eq 0 ] - [ "$output" = "Switched to branch 'test'" ] - run dolt branch - [ "$status" -eq 0 ] - [[ "$output" =~ "* test" ]] || false -} - -@test "delete a branch" { - dolt branch test - run dolt branch -d test - [ "$status" -eq 0 ] - [ "$output" = "" ] - run dolt branch - [[ ! "$output" =~ "test" ]] || false -} - -@test "move a branch" { - dolt branch foo - run dolt branch -m foo bar - [ "$status" -eq 0 ] - [ "$output" = "" ] - run dolt branch - [[ ! "$output" =~ "foo" ]] || false - [[ "$output" =~ "bar" ]] || false -} - -@test "copy a branch" { - dolt branch foo - run dolt branch -c foo bar - [ "$status" -eq 0 ] - [ "$output" = "" ] - run dolt branch - [[ "$output" =~ "foo" ]] || false - [[ "$output" =~ "bar" ]] || false -} - -@test "branch names must support /" { - run dolt branch tim/test-this-format-11 - [ "$status" -eq 0 ] - [ "$output" = "" ] -} - -@test "branch names do not support ." { - run dolt branch "dots.are.not.supported" - [ "$status" -eq 1 ] - [ "$output" = "fatal: 'dots.are.not.supported' is an invalid branch name." ] -} +#!/usr/bin/env bats +load $BATS_TEST_DIRNAME/helper/common.bash + +setup() { + setup_common +} + +teardown() { + teardown_common +} + +# Tests on an empty dolt repository +@test "dolt init on an already initialized repository" { + run dolt init + [ "$status" -ne 0 ] + [ "$output" = "This directory has already been initialized." ] +} + +@test "dolt status on a new repository" { + run dolt status + [ "$status" -eq 0 ] + [ "${lines[0]}" = "On branch master" ] + [ "${lines[1]}" = "Untracked files:" ] + [ "${lines[2]}" = ' (use "dolt add " to include in what will be committed)' ] + [[ "${lines[3]}" =~ ([[:space:]]*new doc:[[:space:]]*LICENSE.md) ]] || false + [[ "${lines[4]}" =~ ([[:space:]]*new doc:[[:space:]]*README.md) ]] || false + run ls + [ "${lines[0]}" = "LICENSE.md" ] + [ "${lines[1]}" = "README.md" ] + # L&R must be removed (or added and committed) for `nothing to commit` message to display + run rm "LICENSE.md" + run rm "README.md" + run dolt status + [ "$status" -eq 0 ] + [ "${lines[0]}" = "On branch master" ] + [ "${lines[1]}" = "nothing to commit, working tree clean" ] +} + +@test "dolt ls in a new repository" { + run dolt ls + [ "$status" -eq 0 ] + [ "$output" = "No tables in working set" ] +} + +@test "dolt branch in a new repository" { + run dolt branch + [ "$status" -eq 0 ] + # I can't seem to get this to match "* master" so I made a regex instead + # [ "$output" = "* master" ] + [[ "$output" =~ "* master" ]] || false +} + +@test "dolt log in a new repository" { + run dolt log + [ "$status" -eq 0 ] + [[ "$output" =~ "commit " ]] || false + [[ "$output" =~ "Initialize data repository" ]] || false +} + +@test "dolt add . in new repository" { + run dolt add . + [ "$status" -eq 0 ] + [ "$output" = "" ] +} + +@test "dolt reset in new repository" { + run dolt reset + [ "$status" -eq 0 ] + [ "$output" = "" ] +} + +@test "dolt diff in new repository" { + run dolt diff + [ "$status" -eq 0 ] + [[ "$output" =~ "diff --dolt a/LICENSE.md b/LICENSE.md" ]] || false + [[ "$output" =~ "diff --dolt a/README.md b/README.md" ]] || false + [[ "$output" =~ "added doc" ]] || false +} + +@test "dolt commit with nothing added" { + # L&R must be removed (or added and committed) in order to test `no changes added to commit` message + rm "LICENSE.md" + rm "README.md" + run dolt commit -m "commit" + [ "$status" -eq 1 ] + [ "$output" = 'no changes added to commit (use "dolt add")' ] +} + +@test "dolt commit --allow-empty with nothing added" { + run dolt commit -m "distinctively-named commit" --allow-empty + [ "$status" -eq 0 ] + run dolt log + [[ "$output" =~ "distinctively-named commit" ]] || false +} + +@test "dolt sql in a new repository" { + run dolt sql -q "select * from test" + [ "$status" -eq 1 ] + [[ "$output" = "table not found: test" ]] || false +} + +@test "invalid sql in a new repository" { + run dolt sql -q "foo bar" + [ "$status" -eq 1 ] + [[ "$output" =~ "Error parsing SQL" ]] || false +} + +@test "dolt schema show in new repository" { + run dolt schema show + [ "$status" -eq 1 ] + [[ "$output" =~ "usage" ]] || false +} + +@test "dolt table select in new repository" { + run dolt sql -q "select * from test" + [ "$status" -ne 0 ] +} + +@test "dolt table import in a new repository" { + run dolt table import + [ "$status" -ne 0 ] + [[ "${lines[0]}" =~ "usage" ]] || false +} + +@test "dolt table export in a new repository" { + run dolt table export + [ "$status" -ne 0 ] + [[ "${lines[0]}" =~ "usage" ]] || false +} + +@test "dolt table rm in a new repository" { + run dolt table rm + [ "$status" -ne 0 ] + [[ "${lines[0]}" =~ "usage" ]] || false +} + +@test "dolt table cp in a new repository" { + run dolt table cp + [ "$status" -ne 0 ] + [[ "${lines[0]}" =~ "usage" ]] || false +} + +@test "dolt checkout master on master" { + run dolt checkout master + [ "$status" -eq 1 ] + [ "$output" = "Already on branch 'master'" ] +} + +@test "dolt checkout non-existant branch" { + run dolt checkout foo + [ "$status" -ne 0 ] + [ "$output" = "error: could not find foo" ] +} + +@test "create and checkout a branch" { + run dolt branch test + [ "$status" -eq 0 ] + [ "$output" = "" ] + run dolt checkout test + [ "$status" -eq 0 ] + [ "$output" = "Switched to branch 'test'" ] + run dolt branch + [ "$status" -eq 0 ] + [[ "$output" =~ "* test" ]] || false +} + +@test "create and checkout a branch with dolt checkout -b" { + run dolt checkout -b test + [ "$status" -eq 0 ] + [ "$output" = "Switched to branch 'test'" ] + run dolt branch + [ "$status" -eq 0 ] + [[ "$output" =~ "* test" ]] || false +} + +@test "delete a branch" { + dolt branch test + run dolt branch -d test + [ "$status" -eq 0 ] + [ "$output" = "" ] + run dolt branch + [[ ! "$output" =~ "test" ]] || false +} + +@test "move a branch" { + dolt branch foo + run dolt branch -m foo bar + [ "$status" -eq 0 ] + [ "$output" = "" ] + run dolt branch + [[ ! "$output" =~ "foo" ]] || false + [[ "$output" =~ "bar" ]] || false +} + +@test "copy a branch" { + dolt branch foo + run dolt branch -c foo bar + [ "$status" -eq 0 ] + [ "$output" = "" ] + run dolt branch + [[ "$output" =~ "foo" ]] || false + [[ "$output" =~ "bar" ]] || false +} + +@test "branch names must support /" { + run dolt branch tim/test-this-format-11 + [ "$status" -eq 0 ] + [ "$output" = "" ] +} + +@test "branch names do not support ." { + run dolt branch "dots.are.not.supported" + [ "$status" -eq 1 ] + [ "$output" = "fatal: 'dots.are.not.supported' is an invalid branch name." ] +} diff --git a/bats/multiple-tables.bats b/bats/multiple-tables.bats index 4c2626c0483..9b8c09fbeb2 100755 --- a/bats/multiple-tables.bats +++ b/bats/multiple-tables.bats @@ -45,7 +45,7 @@ teardown() { [ "$status" -eq 0 ] [[ "$output" =~ "test1 @ working" ]] || false [[ "$output" =~ "test2 @ working" ]] || false - run dolt status + run dolt status [ "$status" -eq 0 ] [[ "$output" =~ "test1" ]] || false [[ "$output" =~ "test2" ]] || false @@ -84,7 +84,7 @@ teardown() { run dolt reset test1 test2 [ "$status" -eq 0 ] [ "$output" = "" ] - run dolt status + run dolt status [[ ! "$output" =~ "Changes to be committed" ]] || false [[ "$output" =~ "Untracked files" ]] || false run dolt add . @@ -103,7 +103,7 @@ teardown() { run dolt reset . [ "$status" -eq 0 ] [ "$output" = "" ] - run dolt status + run dolt status [[ ! "$output" =~ "Changes to be committed" ]] || false [[ "$output" =~ "Untracked files" ]] || false } @@ -116,7 +116,7 @@ teardown() { run dolt reset . [ "$status" -eq 0 ] [ "$output" = "" ] - run dolt status + run dolt status [[ ! "$output" =~ "Changes to be committed" ]] || false [[ "$output" =~ "Untracked files" ]] || false diff --git a/bats/no-repo.bats b/bats/no-repo.bats index 4ad712c1bf6..c5da6287166 100755 --- a/bats/no-repo.bats +++ b/bats/no-repo.bats @@ -1,212 +1,212 @@ -#!/usr/bin/env bats -load $BATS_TEST_DIRNAME/helper/common.bash - -setup() { - setup_common - mkdir no-dolt-dir-$$ - cd no-dolt-dir-$$ -} - -teardown() { - teardown_common - rm -rf $BATS_TMPDIR/no-dolt-dir-$$ -} - -@test "checking we have a dolt executable available" { - command -v dolt -} - -@test "invoking dolt with no arguments" { - run dolt - [ "$status" -eq 1 ] - [ "${lines[0]}" = "Valid commands for dolt are" ] - # Check help output for supported commands - [[ "$output" =~ "init -" ]] || false - [[ "$output" =~ "status -" ]] || false - [[ "$output" =~ "add -" ]] || false - [[ "$output" =~ "reset -" ]] || false - [[ "$output" =~ "commit -" ]] || false - [[ "$output" =~ "sql -" ]] || false - [[ "$output" =~ "log -" ]] || false - [[ "$output" =~ "diff -" ]] || false - [[ "$output" =~ "merge -" ]] || false - [[ "$output" =~ "branch -" ]] || false - [[ "$output" =~ "checkout -" ]] || false - [[ "$output" =~ "remote -" ]] || false - [[ "$output" =~ "push -" ]] || false - [[ "$output" =~ "pull -" ]] || false - [[ "$output" =~ "fetch -" ]] || false - [[ "$output" =~ "clone -" ]] || false - [[ "$output" =~ "creds -" ]] || false - [[ "$output" =~ "login -" ]] || false - [[ "$output" =~ "version -" ]] || false - [[ "$output" =~ "config -" ]] || false - [[ "$output" =~ "ls -" ]] || false - [[ "$output" =~ "table -" ]] || false - [[ "$output" =~ "conflicts -" ]] || false -} - -@test "testing dolt version output" { - run dolt version - [ "$status" -eq 0 ] - [[ "$output" =~ "dolt version " ]] || false -} - - -# Tests for dolt commands outside of a dolt repository -NOT_VALID_REPO_ERROR="The current directory is not a valid dolt repository." -@test "dolt status outside of a dolt repository" { - run dolt status - [ "$status" -ne 0 ] - [ "${lines[0]}" = "$NOT_VALID_REPO_ERROR" ] -} - -@test "dolt add outside of a dolt repository" { - run dolt add - [ "$status" -ne 0 ] - [ "${lines[0]}" = "$NOT_VALID_REPO_ERROR" ] -} - -@test "dolt reset outside of a dolt repository" { - run dolt reset - [ "$status" -ne 0 ] - [ "${lines[0]}" = "$NOT_VALID_REPO_ERROR" ] -} - -@test "dolt commit outside of a dolt repository" { - run dolt commit - [ "$status" -ne 0 ] - [ "${lines[0]}" = "$NOT_VALID_REPO_ERROR" ] -} - -@test "dolt log outside of a dolt repository" { - run dolt log - [ "$status" -ne 0 ] - [ "${lines[0]}" = "$NOT_VALID_REPO_ERROR" ] -} - -@test "dolt diff outside of a dolt repository" { - run dolt diff - [ "$status" -ne 0 ] - [ "${lines[0]}" = "$NOT_VALID_REPO_ERROR" ] -} - -@test "dolt merge outside of a dolt repository" { - run dolt merge - [ "$status" -ne 0 ] - [ "${lines[0]}" = "$NOT_VALID_REPO_ERROR" ] -} - -@test "dolt branch outside of a dolt repository" { - run dolt branch - [ "$status" -ne 0 ] - [ "${lines[0]}" = "$NOT_VALID_REPO_ERROR" ] -} - -@test "dolt sql outside of a dolt repository" { - run dolt sql - [ "$status" -ne 0 ] - [ "${lines[0]}" = "$NOT_VALID_REPO_ERROR" ] -} - -@test "dolt checkout outside of a dolt repository" { - run dolt checkout - [ "$status" -ne 0 ] - [ "${lines[0]}" = "$NOT_VALID_REPO_ERROR" ] -} - -@test "dolt remote outside of a dolt repository" { - run dolt remote - [ "$status" -ne 0 ] - [ "${lines[0]}" = "$NOT_VALID_REPO_ERROR" ] -} - -@test "dolt push outside of a dolt repository" { - run dolt push - [ "$status" -ne 0 ] - [ "${lines[0]}" = "$NOT_VALID_REPO_ERROR" ] -} - -@test "dolt pull outside of a dolt repository" { - run dolt pull - [ "$status" -ne 0 ] - [ "${lines[0]}" = "$NOT_VALID_REPO_ERROR" ] -} - -@test "dolt fetch outside of a dolt repository" { - run dolt fetch - [ "$status" -ne 0 ] - [ "${lines[0]}" = "$NOT_VALID_REPO_ERROR" ] -} - -@test "dolt ls outside of a dolt repository" { - run dolt ls - [ "$status" -ne 0 ] - [ "${lines[0]}" = "$NOT_VALID_REPO_ERROR" ] -} - -@test "dolt table outside of a dolt repository" { - run dolt table - [ "$status" -ne 0 ] - [ "${lines[0]}" = "Valid commands for dolt table are" ] - # Check help output for supported commands - [[ "$output" =~ "import -" ]] || false - [[ "$output" =~ "export -" ]] || false - [[ "$output" =~ "rm -" ]] || false - [[ "$output" =~ "mv -" ]] || false - [[ "$output" =~ "cp -" ]] || false -} - -@test "dolt table import outside of a dolt repository" { - run dolt table import - [ "$status" -ne 0 ] - [ "${lines[0]}" = "$NOT_VALID_REPO_ERROR" ] -} - -@test "dolt table rm outside of a dolt repository" { - run dolt table rm - [ "$status" -ne 0 ] - [ "${lines[0]}" = "$NOT_VALID_REPO_ERROR" ] -} - -@test "dolt table mv outside of a dolt repository" { - run dolt table mv - [ "$status" -ne 0 ] - [ "${lines[0]}" = "$NOT_VALID_REPO_ERROR" ] -} - -@test "dolt table cp outside of a dolt repository" { - run dolt table cp - [ "$status" -ne 0 ] - [ "${lines[0]}" = "$NOT_VALID_REPO_ERROR" ] -} - -@test "dolt schema show outside of a dolt repository" { - run dolt schema show - [ "$status" -ne 0 ] - [ "${lines[0]}" = "$NOT_VALID_REPO_ERROR" ] -} - -@test "dolt conflicts outside of a dolt repository" { - run dolt conflicts - [ "$status" -ne 0 ] - [ "${lines[0]}" = "Valid commands for dolt conflicts are" ] - # Check help output for supported commands - [[ "$output" =~ "cat -" ]] || false - [[ "$output" =~ "resolve -" ]] || false -} - -@test "initializing a dolt repository" { - mkdir dolt-repo-$$-new - cd dolt-repo-$$-new - run dolt init - [ "$status" -eq 0 ] - [ "$output" = "Successfully initialized dolt data repository." ] - [ -d .dolt ] - [ -d .dolt/noms ] - [ -f .dolt/config.json ] - [ -f .dolt/repo_state.json ] - [ -f README.md ] - [ -f LICENSE.md ] - rm -rf $BATS_TMPDIR/dolt-repo-$$-new -} +#!/usr/bin/env bats +load $BATS_TEST_DIRNAME/helper/common.bash + +setup() { + setup_common + mkdir no-dolt-dir-$$ + cd no-dolt-dir-$$ +} + +teardown() { + teardown_common + rm -rf $BATS_TMPDIR/no-dolt-dir-$$ +} + +@test "checking we have a dolt executable available" { + command -v dolt +} + +@test "invoking dolt with no arguments" { + run dolt + [ "$status" -eq 1 ] + [ "${lines[0]}" = "Valid commands for dolt are" ] + # Check help output for supported commands + [[ "$output" =~ "init -" ]] || false + [[ "$output" =~ "status -" ]] || false + [[ "$output" =~ "add -" ]] || false + [[ "$output" =~ "reset -" ]] || false + [[ "$output" =~ "commit -" ]] || false + [[ "$output" =~ "sql -" ]] || false + [[ "$output" =~ "log -" ]] || false + [[ "$output" =~ "diff -" ]] || false + [[ "$output" =~ "merge -" ]] || false + [[ "$output" =~ "branch -" ]] || false + [[ "$output" =~ "checkout -" ]] || false + [[ "$output" =~ "remote -" ]] || false + [[ "$output" =~ "push -" ]] || false + [[ "$output" =~ "pull -" ]] || false + [[ "$output" =~ "fetch -" ]] || false + [[ "$output" =~ "clone -" ]] || false + [[ "$output" =~ "creds -" ]] || false + [[ "$output" =~ "login -" ]] || false + [[ "$output" =~ "version -" ]] || false + [[ "$output" =~ "config -" ]] || false + [[ "$output" =~ "ls -" ]] || false + [[ "$output" =~ "table -" ]] || false + [[ "$output" =~ "conflicts -" ]] || false +} + +@test "testing dolt version output" { + run dolt version + [ "$status" -eq 0 ] + [[ "$output" =~ "dolt version " ]] || false +} + + +# Tests for dolt commands outside of a dolt repository +NOT_VALID_REPO_ERROR="The current directory is not a valid dolt repository." +@test "dolt status outside of a dolt repository" { + run dolt status + [ "$status" -ne 0 ] + [ "${lines[0]}" = "$NOT_VALID_REPO_ERROR" ] +} + +@test "dolt add outside of a dolt repository" { + run dolt add + [ "$status" -ne 0 ] + [ "${lines[0]}" = "$NOT_VALID_REPO_ERROR" ] +} + +@test "dolt reset outside of a dolt repository" { + run dolt reset + [ "$status" -ne 0 ] + [ "${lines[0]}" = "$NOT_VALID_REPO_ERROR" ] +} + +@test "dolt commit outside of a dolt repository" { + run dolt commit + [ "$status" -ne 0 ] + [ "${lines[0]}" = "$NOT_VALID_REPO_ERROR" ] +} + +@test "dolt log outside of a dolt repository" { + run dolt log + [ "$status" -ne 0 ] + [ "${lines[0]}" = "$NOT_VALID_REPO_ERROR" ] +} + +@test "dolt diff outside of a dolt repository" { + run dolt diff + [ "$status" -ne 0 ] + [ "${lines[0]}" = "$NOT_VALID_REPO_ERROR" ] +} + +@test "dolt merge outside of a dolt repository" { + run dolt merge + [ "$status" -ne 0 ] + [ "${lines[0]}" = "$NOT_VALID_REPO_ERROR" ] +} + +@test "dolt branch outside of a dolt repository" { + run dolt branch + [ "$status" -ne 0 ] + [ "${lines[0]}" = "$NOT_VALID_REPO_ERROR" ] +} + +@test "dolt sql outside of a dolt repository" { + run dolt sql + [ "$status" -ne 0 ] + [ "${lines[0]}" = "$NOT_VALID_REPO_ERROR" ] +} + +@test "dolt checkout outside of a dolt repository" { + run dolt checkout + [ "$status" -ne 0 ] + [ "${lines[0]}" = "$NOT_VALID_REPO_ERROR" ] +} + +@test "dolt remote outside of a dolt repository" { + run dolt remote + [ "$status" -ne 0 ] + [ "${lines[0]}" = "$NOT_VALID_REPO_ERROR" ] +} + +@test "dolt push outside of a dolt repository" { + run dolt push + [ "$status" -ne 0 ] + [ "${lines[0]}" = "$NOT_VALID_REPO_ERROR" ] +} + +@test "dolt pull outside of a dolt repository" { + run dolt pull + [ "$status" -ne 0 ] + [ "${lines[0]}" = "$NOT_VALID_REPO_ERROR" ] +} + +@test "dolt fetch outside of a dolt repository" { + run dolt fetch + [ "$status" -ne 0 ] + [ "${lines[0]}" = "$NOT_VALID_REPO_ERROR" ] +} + +@test "dolt ls outside of a dolt repository" { + run dolt ls + [ "$status" -ne 0 ] + [ "${lines[0]}" = "$NOT_VALID_REPO_ERROR" ] +} + +@test "dolt table outside of a dolt repository" { + run dolt table + [ "$status" -ne 0 ] + [ "${lines[0]}" = "Valid commands for dolt table are" ] + # Check help output for supported commands + [[ "$output" =~ "import -" ]] || false + [[ "$output" =~ "export -" ]] || false + [[ "$output" =~ "rm -" ]] || false + [[ "$output" =~ "mv -" ]] || false + [[ "$output" =~ "cp -" ]] || false +} + +@test "dolt table import outside of a dolt repository" { + run dolt table import + [ "$status" -ne 0 ] + [ "${lines[0]}" = "$NOT_VALID_REPO_ERROR" ] +} + +@test "dolt table rm outside of a dolt repository" { + run dolt table rm + [ "$status" -ne 0 ] + [ "${lines[0]}" = "$NOT_VALID_REPO_ERROR" ] +} + +@test "dolt table mv outside of a dolt repository" { + run dolt table mv + [ "$status" -ne 0 ] + [ "${lines[0]}" = "$NOT_VALID_REPO_ERROR" ] +} + +@test "dolt table cp outside of a dolt repository" { + run dolt table cp + [ "$status" -ne 0 ] + [ "${lines[0]}" = "$NOT_VALID_REPO_ERROR" ] +} + +@test "dolt schema show outside of a dolt repository" { + run dolt schema show + [ "$status" -ne 0 ] + [ "${lines[0]}" = "$NOT_VALID_REPO_ERROR" ] +} + +@test "dolt conflicts outside of a dolt repository" { + run dolt conflicts + [ "$status" -ne 0 ] + [ "${lines[0]}" = "Valid commands for dolt conflicts are" ] + # Check help output for supported commands + [[ "$output" =~ "cat -" ]] || false + [[ "$output" =~ "resolve -" ]] || false +} + +@test "initializing a dolt repository" { + mkdir dolt-repo-$$-new + cd dolt-repo-$$-new + run dolt init + [ "$status" -eq 0 ] + [ "$output" = "Successfully initialized dolt data repository." ] + [ -d .dolt ] + [ -d .dolt/noms ] + [ -f .dolt/config.json ] + [ -f .dolt/repo_state.json ] + [ -f README.md ] + [ -f LICENSE.md ] + rm -rf $BATS_TMPDIR/dolt-repo-$$-new +} diff --git a/bats/remotes.bats b/bats/remotes.bats index 600bcbcbfc2..ecde50bc0ff 100644 --- a/bats/remotes.bats +++ b/bats/remotes.bats @@ -26,7 +26,7 @@ teardown() { run dolt remote add test-remote http://localhost:50051/test-org/test-repo [ "$status" -eq 0 ] [ "$output" = "" ] - run dolt remote -v + run dolt remote -v [ "$status" -eq 0 ] [[ "$output" =~ "test-remote" ]] || false run dolt remote add test-remote @@ -65,7 +65,7 @@ teardown() { [[ "$output" =~ "unknown remote" ]] || false run dolt pull poop [ "$status" -eq 1 ] - [[ "$output" =~ "unknown remote" ]] || false + [[ "$output" =~ "unknown remote" ]] || false } @test "push and pull non-master branch from remote" { @@ -180,7 +180,7 @@ SQL run dolt log [ "$status" -eq 0 ] [[ "$output" =~ "test commit" ]] || false - run dolt remote -v + run dolt remote -v [ "$status" -eq 0 ] [[ "$output" =~ "test-remote" ]] || false [[ ! "$output" =~ "origin" ]] || false @@ -205,7 +205,7 @@ SQL run dolt branch -v -a [ "$status" -eq 0 ] [[ "$output" =~ "remotes/test-remote/poop" ]] || false -} +} @test "dolt merge with origin/master syntax." { dolt remote add test-remote http://localhost:50051/test-org/test-repo @@ -415,7 +415,7 @@ SQL # master hasn't been pushed so expect zzz to be the current branch and the string master should not be present run dolt branch [ "$status" -eq 0 ] - [[ "$output" =~ "aaa" ]] || false + [[ "$output" =~ "aaa" ]] || false [[ "$output" =~ "* zzz" ]] || false [[ ! "$output" =~ "master" ]] || false cd ../.. @@ -427,7 +427,7 @@ SQL # master pushed so it should be the current branch. run dolt branch [ "$status" -eq 0 ] - [[ "$output" =~ "aaa" ]] || false + [[ "$output" =~ "aaa" ]] || false [[ "$output" =~ "zzz" ]] || false [[ "$output" =~ "* master" ]] || false } diff --git a/bats/schema-changes.bats b/bats/schema-changes.bats index 74463531dd2..422c60845ff 100755 --- a/bats/schema-changes.bats +++ b/bats/schema-changes.bats @@ -188,7 +188,7 @@ SQL } @test "adding and dropping column should produce no diff" { - # Remove the docs, otherwise they will show up in the diff below. + # Remove the docs, otherwise they will show up in the diff below. rm LICENSE.md rm README.md dolt sql <file1.txt & pid1=$! @@ -33,7 +33,7 @@ teardown() { # get the line count of each output file event_count1=`wc -l file1.txt` event_count2=`wc -l file2.txt` - + if [ $exit_code1 -eq 0 ]; then if [ $exit_code2 -eq 0 ]; then # we expect for only one output file to contain 4 lines, corresponding to the 4 event files successfully processed diff --git a/bats/update-tables.bats b/bats/update-tables.bats index 145deaff68a..796103786bc 100644 --- a/bats/update-tables.bats +++ b/bats/update-tables.bats @@ -1,15 +1,15 @@ -#!/usr/bin/env bats -load $BATS_TEST_DIRNAME/helper/common.bash - -setup() { - setup_common -} - -teardown() { - teardown_common -} - -@test "update table using csv" { +#!/usr/bin/env bats +load $BATS_TEST_DIRNAME/helper/common.bash + +setup() { + setup_common +} + +teardown() { + teardown_common +} + +@test "update table using csv" { dolt sql <