Skip to content

Commit

Permalink
Add more quotes to tests (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
fishi0x01 authored Jan 27, 2021
1 parent 7db5a57 commit 199741f
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 30 deletions.
30 changes: 13 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
name: CI

on: [push, pull_request]
on:
push:
branches:
- master
pull_request:

jobs:

prepare:
runs-on: ubuntu-latest
if: "! contains(github.event.head_commit.message, 'skip ci')"
steps:
- run: echo "${{ github.event.head_commit.message }}"

build:
needs: prepare
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '1.13.12'
- run: 'go version'
- run: 'make get-bats'
- name: 'build'
run: 'make cross-compile'
- name: 'test'
run: 'make integration-tests'
go-version: 1.15.7
- run: go version
- run: make get-bats
- name: build
run: make cross-compile
- name: test
run: make integration-tests
16 changes: 10 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ PLATFORMS := linux darwin
ARCHS := 386 amd64
VERSION := $(shell git describe --tags --always --dirty)

cross-compile: clean
help: ## Prints help for targets with comments
@grep -E '^[a-zA-Z0-9.\ _-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

cross-compile: clean ## Compile vsh binaries for multiple platforms and architectures
mkdir -p ./build/
for GOOS in $(PLATFORMS); do \
for GOARCH in $(ARCHS); do \
Expand All @@ -13,10 +16,10 @@ cross-compile: clean
done
ls build/

compile: clean
compile: clean ## Compile vsh for platform based on uname
go build -ldflags "-X main.vshVersion=$(VERSION)" -o build/${APP_NAME}_$(shell uname | tr '[:upper:]' '[:lower:]')_amd64

get-bats:
get-bats: ## Download bats dependencies to test directory
rm -rf test/bin/
mkdir -p test/bin/core
mkdir -p test/bin/plugins/bats-assert
Expand All @@ -27,11 +30,12 @@ get-bats:
curl -sL https://github.com/bats-core/bats-support/archive/v0.3.0.tar.gz | tar xvz --strip 1 -C test/bin/plugins/bats-support
curl -sL https://github.com/bats-core/bats-file/archive/v0.2.0.tar.gz | tar xvz --strip 1 -C test/bin/plugins/bats-file

integration-tests:
integration-tests: ## Run integration test suites (requires bats - see get-bats)
test/run.sh

local-vault-test-instance:
local-vault-test-instance: ## Start a local vault container with integration test provisioning
bash -c ". test/util/util.bash && setup"

clean:
clean: ## Remove builds and vsh related docker containers
docker rm -f vsh-integration-test-vault || true
rm ./build/* || true
4 changes: 2 additions & 2 deletions test/suites/commands/append.bats
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ load ../../bin/plugins/bats-assert/load

#######################################
echo "==== case: append to non-existing file ===="
run ${APP_BIN} -c "append ${KV_BACKEND}/src/does/not/exist ${KV_BACKEND}/src/aa"
run ${APP_BIN} -c "append '${KV_BACKEND}/src/does/not/exist' \"${KV_BACKEND}/src/aa\""
assert_failure 1

echo "ensure proper error message"
Expand All @@ -50,7 +50,7 @@ load ../../bin/plugins/bats-assert/load

#######################################
echo "==== case: append value to existing destination with conflicting keys (skip strategy) ===="
run ${APP_BIN} -c "append ${KV_BACKEND}/src/tooling/v1 ${KV_BACKEND}/dest/prod/all --skip"
run ${APP_BIN} -c "append \"${KV_BACKEND}/src/tooling/v1\" '${KV_BACKEND}/dest/prod/all' --skip"
assert_success

echo "ensure the file got appended to destination"
Expand Down
2 changes: 1 addition & 1 deletion test/suites/commands/cat.bats
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ load ../../bin/plugins/bats-assert/load

#######################################
echo "==== case: cat ambiguous directory ===="
run ${APP_BIN} -c "cat ${KV_BACKEND}/src/tooling/"
run ${APP_BIN} -c "cat '${KV_BACKEND}/src/tooling/'"
assert_failure 1
assert_line --partial "Not a valid path for operation: /${KV_BACKEND}/src/tooling/"
}
4 changes: 2 additions & 2 deletions test/suites/commands/cp.bats
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ load ../../bin/plugins/bats-assert/load

#######################################
echo "==== case: copy single directory without trailing '/' ===="
run ${APP_BIN} -c "cp ${KV_BACKEND}/src/dev ${KV_BACKEND}/dest/dev"
run ${APP_BIN} -c "cp '${KV_BACKEND}/src/dev' '${KV_BACKEND}/dest/dev'"
assert_success

echo "ensure the directory got copied to destination"
Expand All @@ -61,7 +61,7 @@ load ../../bin/plugins/bats-assert/load

#######################################
echo "==== case: copy single directory with trailing '/' ===="
run ${APP_BIN} -c "cp ${KV_BACKEND}/src/dev/ ${KV_BACKEND}/dest/dev.copy"
run ${APP_BIN} -c "cp \"${KV_BACKEND}/src/dev/\" \"${KV_BACKEND}/dest/dev.copy\""
assert_success

echo "ensure the directory got copied to destination"
Expand Down
2 changes: 1 addition & 1 deletion test/suites/commands/mv.bats
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ load ../../bin/plugins/bats-assert/load
@test "vault-${VAULT_VERSION} ${KV_BACKEND} 'mv'" {
#######################################
echo "==== case: move single file ===="
run ${APP_BIN} -c "mv ${KV_BACKEND}/src/prod/all ${KV_BACKEND}/dest/prod/all"
run ${APP_BIN} -c "mv '${KV_BACKEND}/src/prod/all' ${KV_BACKEND}/dest/prod/all"
assert_success

echo "ensure the file got moved to destination"
Expand Down
2 changes: 1 addition & 1 deletion test/suites/commands/rm.bats
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ load ../../bin/plugins/bats-assert/load
assert_success
assert_output "v2"

run ${APP_BIN} -c "rm ${KV_BACKEND}/src/staging/all/"
run ${APP_BIN} -c "rm \"${KV_BACKEND}/src/staging/all/\""
assert_success

echo "ensure the directory got removed"
Expand Down

0 comments on commit 199741f

Please sign in to comment.