diff --git a/.gitmodules b/.gitmodules index 2e33a42ea..8ea50071e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,3 +10,6 @@ [submodule "tests/lib/bats-support"] path = tests/lib/bats-support url = https://github.com/crowdsecurity/bats-support.git +[submodule "tests/lib/bats-mock"] + path = tests/lib/bats-mock + url = https://github.com/crowdsecurity/bats-mock.git diff --git a/tests/README.md b/tests/README.md index e467f159f..8c6a68094 100644 --- a/tests/README.md +++ b/tests/README.md @@ -108,6 +108,7 @@ You can find here the documentation for the main framework and the plugins we us - [bats-assert](https://github.com/bats-core/bats-assert) - [bats-support](https://github.com/bats-core/bats-support) - [bats-file](https://github.com/bats-core/bats-file) + - [bats-mock](https://github.com/grayhemp/bats-mock) > As it often happens with open source, the first results from search engines refer to the old, unmaintained forks. > Be sure to use the links above to find the good versions. @@ -310,6 +311,12 @@ We included the [bats-file](https://github.com/bats-core/bats-file) plugin to check the result of file system operations: existence, type/size/ownership checks on files, symlinks, directories, sockets. +## mocking external commands + +The [bats-mock](https://github.com/grayhemp/bats-mock) plugin allows you to define +a "fake" behavior for the external commands called by a package under test, and +to record and assert which parameters are passed to it. + ## gotchas - pay attention to tests that are not run - for example "bats warning: Executed 143 diff --git a/tests/lib/bats-mock b/tests/lib/bats-mock new file mode 160000 index 000000000..48fce7448 --- /dev/null +++ b/tests/lib/bats-mock @@ -0,0 +1 @@ +Subproject commit 48fce74482a4d2bb879b904ccab31b6bc98e3224