My MItamae cookbooks
Cookbooks for MItamae.
Testing
verify
definition
The All cookbooks should have verify
to verify the result.
For example: a cookbook to create "/foo/bar"
directory
include_recipe "../core/verify.rb"
directory "/foo/bar"
verify <<-SH
test -d "/foo/bar"
SH
Pass a shell script to verify
to verify. That script' exit code must be zero ($? -eq 0
), otherwise verify
recognize it is failed or broken.
Note that the shell script will be added -e
flag automatically. All command lines must exit with 0.
Running test / develop a new cookbook
Just run mitamae local [recipe file]
to test a cookbook. All cookbooks have a verify
as above.
Docker is useful for a test. Following interaction is a good way to test from the ground:
$ docker build -t mitamae-test .
$ docker run -v $PWD:/mitamae/repo mitamae-test ./mitamae local repo/cookbooks/git/default.rb
Also you can check the cookbook from Docker container as try-and-error approach:
$ docker run -it -v $PWD:/mitamae/repo mitamae-test bash
root@3c99719d987b:/mitamae# ./mitamae local -l debug ./repo/cookbooks/git/default.rb
See ./test/ directory for a detail.