Files
dolt/integration-tests/bats
Maximilian Hoffman 4a994d31c6 Read replica update working set fixes (#3471)
* 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>
2022-05-23 15:00:11 -07:00
..
2022-05-18 13:58:52 -07:00
.
2022-05-18 15:16:30 -07:00
2021-11-08 13:28:51 -08:00
2022-05-10 14:08:47 -07:00
2022-05-10 14:08:47 -07:00
2022-04-22 09:40:53 -07:00
2021-08-11 10:57:05 -07:00
2022-03-15 16:38:15 -07:00
2022-05-10 14:08:47 -07:00
2022-05-10 14:08:47 -07:00
2022-05-17 11:25:51 -07:00
2022-05-10 14:08:47 -07:00
2022-05-10 14:34:05 -07:00
2022-05-10 14:08:47 -07:00
2022-05-10 14:08:47 -07:00
2022-02-11 14:04:21 -08:00
2021-12-15 11:03:59 -08:00
2022-05-10 14:08:47 -07:00
2022-05-10 14:34:05 -07:00
2021-08-06 12:38:14 -07:00
2022-05-10 15:01:20 -07:00
2022-05-10 14:08:47 -07:00
2022-05-10 14:08:47 -07:00
2022-05-18 14:02:43 -07:00
2022-05-17 11:44:11 -07:00
2022-05-11 19:25:55 -07:00
2022-05-17 11:44:11 -07:00
2022-05-18 14:26:20 -07:00
2022-05-06 18:42:13 -07:00
2022-05-17 18:38:24 -07:00
2022-05-10 15:01:20 -07:00
2022-05-17 17:09:57 -07:00
2022-05-10 14:08:47 -07:00
2022-05-10 14:08:47 -07:00
2022-05-10 14:08:47 -07:00
2022-05-10 14:08:47 -07:00
2022-05-10 14:08:47 -07:00
2022-05-19 08:07:33 -07:00
2022-05-17 11:44:11 -07:00
2022-05-10 14:34:05 -07:00
2022-05-10 14:08:47 -07:00
2022-05-10 14:08:47 -07:00
2022-05-10 14:08:47 -07:00
2022-05-10 14:34:05 -07:00
2022-05-10 14:08:47 -07:00

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

  1. Install bats.
npm install -g bats
  1. Install dolt, git-dolt, git-dolt-smudge, and noms
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 -
  1. 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.