add bats-mock to mock external commands in functional tests (#1529)
This commit is contained in:
parent
e6a2a7386c
commit
bf3ea71630
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -10,3 +10,6 @@
|
||||||
[submodule "tests/lib/bats-support"]
|
[submodule "tests/lib/bats-support"]
|
||||||
path = tests/lib/bats-support
|
path = tests/lib/bats-support
|
||||||
url = https://github.com/crowdsecurity/bats-support.git
|
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
|
||||||
|
|
|
@ -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-assert](https://github.com/bats-core/bats-assert)
|
||||||
- [bats-support](https://github.com/bats-core/bats-support)
|
- [bats-support](https://github.com/bats-core/bats-support)
|
||||||
- [bats-file](https://github.com/bats-core/bats-file)
|
- [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.
|
> 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.
|
> 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
|
check the result of file system operations: existence, type/size/ownership checks
|
||||||
on files, symlinks, directories, sockets.
|
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
|
## gotchas
|
||||||
|
|
||||||
- pay attention to tests that are not run - for example "bats warning: Executed 143
|
- pay attention to tests that are not run - for example "bats warning: Executed 143
|
||||||
|
|
1
tests/lib/bats-mock
Submodule
1
tests/lib/bats-mock
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 48fce74482a4d2bb879b904ccab31b6bc98e3224
|
Loading…
Reference in a new issue