Files
dolt/bats/sql-commit.bats
VinaiRachakonda 1643808f27 add bats file
2020-11-30 13:04:07 -05:00

57 lines
1.2 KiB
Bash

#!/usr/bin/env bats
load $BATS_TEST_DIRNAME/helper/common.bash
setup() {
setup_common
dolt sql <<SQL
CREATE TABLE test (
pk int primary key
);
INSERT INTO test VALUES (0),(1),(2);
SQL
dolt add .
dolt sql <<SQL
DELETE FROM test WHERE pk = 0;
INSERT INTO test VALUES (3);
SQL
dolt add .
}
teardown() {
teardown_common
}
@test "DOLT_COMMIT with a message and author" {
run dolt sql -q "SELECT DOLT_COMMIT('-m', 'Commit1', '--author', 'John Doe <john@doe.com>')"
[ $status -eq 0 ]
run dolt log
[ $status -eq 0 ]
[[ "$output" =~ "Commit1" ]] || false
run dolt log
[ $status -eq 0 ]
regex='John Doe <john@doe.com>'
[[ "$output" =~ "$regex" ]] || false
}
@test "DOLT_COMMIT without a message throws error" {
run dolt sql -q "SELECT DOLT_COMMIT()"
[ $status -eq 1 ]
run dolt log
[ $status -eq 0 ]
regex='Initialize'
[[ "$output" =~ "$regex" ]] || false
}
@test "DOLT_COMMIT with a message and no author throws error" {
run dolt sql -q "SELECT DOLT_COMMIT('-m', 'Commit1')"
[ $status -eq 1 ]
run dolt log
[ $status -eq 0 ]
regex='Initialize'
[[ "$output" =~ "$regex" ]] || false
}