Permalink
Browse files

add bats submodules, add initial bats tests and helper

  • Loading branch information...
patthiel committed Jul 23, 2018
1 parent e304547 commit f197144c7b7c7a3877f02afd83ebc22184f52573
Showing with 54 additions and 0 deletions.
  1. +2 −0 .gitignore
  2. +6 −0 .gitmodules
  3. +9 −0 test/common.bash
  4. +37 −0 test/linodes/linodes.bats.sh
View
@@ -6,3 +6,5 @@ dist
linode-cli.sh
data-2
data-3
.DS_STORE
test/test_helper
View
@@ -0,0 +1,6 @@
[submodule "test/test_helper/bats-assert"]
path = test/test_helper/bats-assert
url = https://github.com/ztombol/bats-assert
[submodule "test/test_helper/bats-support"]
path = test/test_helper/bats-support
url = https://github.com/ztombol/bats-support
View
@@ -0,0 +1,9 @@
removeLinodes() {
local linode_ids="( $(linode-cli --text --no-headers linodes list | awk '{ print $1 }' | xargs) )"
local id
for id in $linode_ids ; do
run bash -c "linode-cli linodes delete $id"
[ "$status" -eq 0 ]
done
}
@@ -0,0 +1,37 @@
#!/usr/bin/env bats
load '../test_helper/bats-support/load'
load '../test_helper/bats-assert/load'
load '../common'
@test "it should create linodes with a label" {
run linode-cli linodes create --type g6-standard-2 --region us-east --image linode/debian9 --label cli-1 --root_pass badDSFS8942 --text --delimiter "," --no-headers
assert_output --regexp '.*,cli-1,us-east,g6-standard-2,linode\/debian9,.*'
}
@test "it should view the linode configuration" {
linode_id="$(linode-cli --text --no-headers linodes list | awk '{ print $1 }' | xargs)"
run linode-cli linodes view "$linode_id" --text --delimiter "," --no-headers
assert_output --regexp "$linode_id,cli-1,us-east,g6-standard-2,linode\/debian9,.*"
}
@test "it should create a linode with the minimum required props" {
run linode-cli linodes create --type g6-standard-2 --region us-east --root_pass badDSFS8942
[ "$status" -eq 0 ]
}
# ONLY WORKS BECAUSE I HAVE A .linode-cli
@test "it should fail to create a linode without a root_pass" {
run linode-cli linodes create --type g6-standard-2 --region us-east
[ "$status" -eq 1 ]
}
@test "it should list linodes" {
run bash -c "linode-cli --text --no-headers linodes list | grep cli-1"
[ "$status" -eq 0 ]
}
@test "it should remove all linodes" {
run removeLinodes
}

0 comments on commit f197144

Please sign in to comment.