Skip to content

Commit

Permalink
Make the relative plan sourcing be independant of where the script is
Browse files Browse the repository at this point in the history
sourced from

This is needed by the bats tests which source the plan.sh for variables
but have cwd set to the `/tests/` subdir so the bare relative linking
doesn't work.

Signed-off-by: James Casey <james@chef.io>
  • Loading branch information
James Casey committed Sep 12, 2018
1 parent 650b044 commit 4b263d1
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 10 deletions.
3 changes: 2 additions & 1 deletion postgresql93/plan.sh
@@ -1,5 +1,6 @@
# shellcheck disable=SC2148,SC1091
source ../postgresql/plan.sh
PLANDIR=$(dirname "${BASH_SOURCE[0]}")
source "${PLANDIR}/../postgresql/plan.sh"

pkg_name=postgresql93
pkg_version=9.3.23
Expand Down
3 changes: 2 additions & 1 deletion postgresql94/plan.sh
@@ -1,5 +1,6 @@
# shellcheck disable=SC2148,SC1091
source ../postgresql/plan.sh
PLANDIR=$(dirname "${BASH_SOURCE[0]}")
source "${PLANDIR}/../postgresql/plan.sh"

pkg_name=postgresql94
pkg_version=9.4.18
Expand Down
3 changes: 2 additions & 1 deletion postgresql95/plan.sh
@@ -1,5 +1,6 @@
# shellcheck disable=SC2148,SC1091
source ../postgresql/plan.sh
PLANDIR=$(dirname "${BASH_SOURCE[0]}")
source "${PLANDIR}/../postgresql/plan.sh"

pkg_name=postgresql95
pkg_version=9.5.13
Expand Down
3 changes: 2 additions & 1 deletion postgresql96/plan.sh
@@ -1,5 +1,6 @@
# shellcheck disable=SC2148,SC1091
source ../postgresql/plan.sh
PLANDIR=$(dirname "${BASH_SOURCE[0]}")
source "${PLANDIR}/../postgresql/plan.sh"

pkg_name=postgresql96
pkg_version=9.6.9
Expand Down
12 changes: 7 additions & 5 deletions postgresql96/tests/extra_data_files.bats
@@ -1,4 +1,6 @@
NONHAB_FILE="/hab/svc/postgresql96/data/lost+found"
source "${BATS_TEST_DIRNAME}/../plan.sh"

NONHAB_FILE="/hab/svc/${pkg_name}/data/lost+found"

function setup() {
touch "${NONHAB_FILE}"
Expand All @@ -11,10 +13,10 @@ function teardown() {
}

@test "Non-hab owned files in /data are allowed" {
ORIGIN=$(hab svc status |grep postgresql96| cut -f1 -d'/')
hab svc stop "${ORIGIN}/postgresql96"
ORIGIN=$(hab svc status |grep ${pkg_name}| cut -f1 -d'/')
hab svc stop "${ORIGIN}/${pkg_name}"

hab svc start "${ORIGIN}/postgresql96"
hab svc start "${ORIGIN}/${pkg_name}"

# Wait for service to start
sleep 1
Expand All @@ -25,5 +27,5 @@ function teardown() {
[ "root" == $(stat -c %G "${NONHAB_FILE}") ]
[ "-rw-------" == $(stat -c %A "${NONHAB_FILE}") ]

[ "$(hab svc status | grep "postgresql96.default" | awk '{print $4}' | grep up)" ]
[ "$(hab svc status | grep "${pkg_name}.default" | awk '{print $4}' | grep up)" ]
}
2 changes: 1 addition & 1 deletion postgresql96/tests/test.bats
Expand Up @@ -12,7 +12,7 @@ source "${BATS_TEST_DIRNAME}/../plan.sh"
}

@test "Service is running" {
[ "$(hab svc status | grep "postgresql96\.default" | awk '{print $4}' | grep up)" ]
[ "$(hab svc status | grep "${pkg_name}\.default" | awk '{print $4}' | grep up)" ]
}

@test "A single process" {
Expand Down

0 comments on commit 4b263d1

Please sign in to comment.