Bladeren bron

add bats-mock to mock external commands in functional tests (#1529)

mmetc 3 jaren geleden
bovenliggende
commit
bf3ea71630
3 gewijzigde bestanden met toevoegingen van 11 en 0 verwijderingen
  1. 3 0
      .gitmodules
  2. 7 0
      tests/README.md
  3. 1 0
      tests/lib/bats-mock

+ 3 - 0
.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

+ 7 - 0
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

+ 1 - 0
tests/lib/bats-mock

@@ -0,0 +1 @@
+Subproject commit 48fce74482a4d2bb879b904ccab31b6bc98e3224