* Read replica update working set fixes Read replica pull updates the session working set after pulling a filtered set of branches from the tracking database. The original (buggy) implementation updates the working set to the branch specified at server-start time. The identity of that branch was fixed for the duration of the server, so dolt_checkout would (appear to) have no effect on the new branch's working set. What actually happened was more pernicious: the working set was updated to the value of the incorrect branch. The fix no longer statically sets the active branch for a read replica database. The active branch is pulled from the `*sql.Context`, so the correct working set will be updated. * [ga-format-pr] Run go/utils/repofmt/format_repo.sh and go/Godeps/update.sh * add test * todos * delete extraeneous line Co-authored-by: max-hoffman <max-hoffman@users.noreply.github.com>
BATS - Bash Automated Testing System
BATS is used to integration test dolt. Our BATS tests started as a humble suite of integration tests. Over two years
of development the suite has grown to over 1,000 tests. When we find a customer facing bug in the dolt command line or
SQL implementation, we cover it with a BATS test. These tests are run on every dolt PR on Mac, Windows, and Linux using
GitHub Actions.
These tests are also useful documentation. If you are wondering how a certain command or feature works in practice,
using grep to find the appropriate BATS test can give you some simple examples of happy path and error case behavior.
The naming conventions for the test files have evolved over time. Generally, the files are named after the feature the
file intends to test. However, some of the early tests are named after the schema of the table they implement
ie. 1pk5col-ints.bats. These files were implemented to reuse setup and teardown logic. This scheme was quickly
abandoned but the legacy remains.
If you find a bug in dolt, we would love a skipped bats test PR in addition to a GitHub issue.
Running for yourself
- Install bats.
npm install -g bats
- Install
dolt,git-dolt,git-dolt-smudge, andnoms
cd go/cmd/dolt && go install . && cd -
cd go/cmd/git-dolt && go install . && cd -
cd go/cmd/git-dolt-smudge && go install . && cd -
cd go/store/cmd/noms && go install . && cd -
- Go to the directory with the bats tests and run:
bats .
This will run all the tests. Specify a particular .bats file to run only those tests.
Here Docs
BATS tests in Dolt make extensive use of Here Docs.
Common patterns include piping SQL scripts to dolt sql:
dolt sql <<SQL
CREATE TABLE my_table (pk int PRIMARY KEY);
SQL
And creating data files for import:
cat <<DELIM > data.csv
pk,c1,c2
1,1,1
2,2,2
DELIM
dolt table import -c -pk=pk my_table data.csv
Skipped BATS
Various tests are skipped as TODOs and/or as documentation of known bugs. Eg:
@test "..." {
...
skip "this test is currently failing because..."
}
Skipped BATS can still be partially useful for testing as they execute normally up to skip statement.
More Information
We published a blog entry on BATS with more information and some useful tips and tricks.