Skip to content
Permalink
Browse files

test: enable travis-ci with bats (#108)

- 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 committed Dec 22, 2018
1 parent 2b5bf4e commit 845f3b690b1ec2e78c02f2482f290fda4dcc6354
Showing with 12 additions and 2 deletions.
  1. +8 −0 .travis.yml
  2. +1 −1 test/{kubectx.sh → kubectx.bats}
  3. +3 −1 test/{kubens.sh → kubens.bats}
@@ -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/
@@ -1,6 +1,6 @@
#!/usr/bin/env bats

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

@test "--help should not fail" {
run ${COMMAND} --help
@@ -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.
You can’t perform that action at this time.