Skip to content
Permalink
Browse files

Add tmp files for unique tags

  • Loading branch information...
patthiel committed Mar 26, 2019
1 parent 5fa76d4 commit 3897e2f71bebc8514e08da4254366298fbdcfc16
Showing with 25 additions and 10 deletions.
  1. +1 −0 .dockerignore
  2. +2 −1 .gitignore
  3. +3 −3 test/common.bash
  4. +4 −3 test/domains/domains-tags.bats
  5. +4 −1 test/linodes/linodes.bats
  6. +7 −2 test/tags/tags.bats
  7. +4 −0 test/test-runner.sh
@@ -1,3 +1,4 @@
build
dist
test/.env
.tmp*
@@ -8,4 +8,5 @@ data-2
data-3
.DS_STORE
Pipfile*
test/.env
test/.env
.tmp*
@@ -6,7 +6,7 @@ if [ -z "$test_image" ]; then
fi

# Random pass to use persistently thorough test run
if [ -z "$random_pass" ]; then
if [ -z "$random_pass" ]; then
export random_pass=$(openssl rand -base64 32)
fi

@@ -76,8 +76,8 @@ removeAll() {
done
}

removeUniqueTag() {
run bash -c "LINODE_CLI_TOKEN=$LINODE_CLI_TOKEN linode-cli tags delete $uniqueTag"
removeTag() {
run bash -c "LINODE_CLI_TOKEN=$LINODE_CLI_TOKEN linode-cli tags delete $1"
}

createLinodeAndWait() {
@@ -61,19 +61,20 @@ teardown() {
--type master \
--soa_email="$email" \
--domain "$timestamp-example.com" \
--tags "$uniqueTag" \
--tags "$tag" \
--format="id,domain,type,status,tags" \
--suppress-warnings \
--text \
--no-header \
--delimiter=","

assert_success
assert_output --regexp "[0-9]+,[0-9]+-example.com,master,active,${uniqueTag}"
assert_output --regexp "[0-9]+,[0-9]+-example.com,master,active,${tag}"
}

@test "it should cleanup domains and tags" {
LAST_TEST="TRUE"
run removeDomains
run removeUniqueTag
run removeTag "foo"
assert_success
}
@@ -116,6 +116,7 @@ teardown() {

@test "it should add a tag a linode" {
local linode_id=$(linode-cli --text --no-headers linodes list | awk '{ print $1 }' | xargs)
echo "export tag=$uniqueTag" > .tmp-linode-tag

run linode-cli linodes update $linode_id \
--tags=$uniqueTag \
@@ -129,6 +130,8 @@ teardown() {

@test "it should remove all linodes" {
LAST_TEST="TRUE"

source .tmp-linode-tag
run removeLinodes
run removeUniqueTag
run removeTag "$tag"
}
@@ -12,6 +12,7 @@ setup() {
teardown() {
if [ "$LAST_TEST" = "TRUE" ]; then
clearToken "$suiteName"
rm .tmp-tag
fi
}

@@ -21,6 +22,7 @@ teardown() {
}

@test "it should create a tag" {
echo "export tag=$uniqueTag" > .tmp-tag
run linode-cli tags create \
--label $uniqueTag \
--text \
@@ -29,12 +31,14 @@ teardown() {
}

@test "it should view the unique tag" {
source .tmp-tag

run linode-cli tags list \
--text \
--no-headers

assert_success
assert_output --partial "$uniqueTag"
assert_output --partial "$tag"
}

@test "it should fail to create a tag shorter than 3 characters" {
@@ -50,7 +54,8 @@ teardown() {

@test "it should remove a tag" {
LAST_TEST="TRUE"
source .tmp-tag

run linode-cli tags delete $uniqueTag
run linode-cli tags delete $tag
assert_success
}
@@ -8,6 +8,10 @@ function ctrl_c() {

unset LINODE_CLI_TOKEN

if [ -f ".tmp-tag" ]; then
rm .tmp-*
fi

echo -e "export TOKEN_1=$TOKEN_1\nexport TOKEN_2=$TOKEN_2\nexport TOKEN_1_IN_USE_BY=NONE\nexport TOKEN_2_IN_USE_BY=NONE" > ./.env
}

0 comments on commit 3897e2f

Please sign in to comment.
You can’t perform that action at this time.