Skip to content

Commit

Permalink
test: enable travis-ci with bats (#108)
Browse files Browse the repository at this point in the history
- add .travis.yml.
- move bats fixtures to .bats extension, since it allows detection of test
files automatically by file extension.
- use BATS_TEST_DIRNAME variable to compute location of COMMAND.
- IMPORTANT: use `echo "$output">&2` before final check so that we can debug
  the test cases by their output

Ref #2.

Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
  • Loading branch information
ahmetb authored Dec 22, 2018
1 parent 2b5bf4e commit 845f3b6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
before_install:
- sudo add-apt-repository ppa:duggan/bats --yes
- sudo apt-get update -qq
- sudo apt-get install -qq bats
- sudo curl -fsSL -o /usr/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/v1.13.1/bin/linux/amd64/kubectl
- sudo chmod +x /usr/bin/kubectl
script:
- bats test/
2 changes: 1 addition & 1 deletion test/kubectx.sh → test/kubectx.bats
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bats

COMMAND=../kubectx
COMMAND="$BATS_TEST_DIRNAME/../kubectx"

@test "--help should not fail" {
run ${COMMAND} --help
Expand Down
4 changes: 3 additions & 1 deletion test/kubens.sh → test/kubens.bats
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#!/usr/bin/env bats

COMMAND=../kubens
COMMAND="${BATS_TEST_DIRNAME}/../kubens"

@test "--help should not fail" {
run ${COMMAND} --help
echo "$output">&2
[ "$status" -eq 0 ]
}

@test "-h should not fail" {
run ${COMMAND} -h
echo "$output">&2
[ "$status" -eq 0 ]
}

0 comments on commit 845f3b6

Please sign in to comment.