diff --git a/CHANGELOG.md b/CHANGELOG.md index f1ee193..e5715aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# 0.1.0 +- add support for homebrew + # 0.0.9 - fix testing for existing groups in user type diff --git a/README.md b/README.md index 5c4dcac..edb7f6e 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,10 @@ Currently supported types are: assert package installed via apt-get on Debian or Ubuntu linux > apt package +* brew +assert package installed via homebrew on OSX +> brew package + * dir assert presence of a directory > dir /tmp/foo diff --git a/VERSION b/VERSION index c5d54ec..6e8bf73 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.0.9 +0.1.0 diff --git a/test/helpers.sh b/test/helpers.sh index a544f48..c5f9f1c 100644 --- a/test/helpers.sh +++ b/test/helpers.sh @@ -27,6 +27,11 @@ skip_linux() { return 0 } +skip_darwin() { + [ "$platform" != "Darwin" ] && skip "requires OSX" + return 0 +} + skip_exec() { exec "$1" [ $? -ne 0 ] && skip "requires $1" diff --git a/test/type-brew.sh b/test/type-brew.sh new file mode 100644 index 0000000..0eb3463 --- /dev/null +++ b/test/type-brew.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bats + +. test/helpers.sh + +fn() { . $BOLT_DIR/types/brew.sh $*; } + +@test "brew status: returns MISSING if package is not present" { + skip_darwin && skip_exec brew + run fn status doesnotexist + [ $status -eq $STATUS_MISSING ] +} + +@test "brew install: installs the package" { + skip_darwin && skip_exec brew + brew remove hr + run fn install hr + [ $status -eq $STATUS_OK ] + which hr + [ $status -eq $STATUS_OK ] +} + +@test "brew status: returns OK if package is present" { + skip_darwin && skip_exec brew + run fn status hr + [ $status -eq $STATUS_OK ] +} diff --git a/types/brew.sh b/types/brew.sh new file mode 100644 index 0000000..1abba3c --- /dev/null +++ b/types/brew.sh @@ -0,0 +1,34 @@ +# modified from original version at https://github.com/mattly/bork + +action=$1 +name=$2 +shift 2 + +case $action in + desc) + echo "assert package installed via homebrew on OSX" + echo "> brew package" + ;; + + status) + platform "Darwin" || return "$STATUS_UNSUPPORTED_PLATFORM" + exec "ruby" || return "$STATUS_FAILED_PRECONDITION" + + echo "$(brew list)" | grep "^$name" + [ "$?" -gt 0 ] && return "$STATUS_MISSING" + + brew outdated $name + [ "$?" -ne 0 ] && return "$STATUS_OUTDATED" + return "$STATUS_OK" + ;; + + install) + brew install $name + ;; + + upgrade) + brew upgrade $name + ;; + + *) return 1 ;; +esac