Permalink
Browse files

Add domains tests

  • Loading branch information...
patthiel committed Aug 13, 2018
1 parent fa3d9cb commit aebceb9387a199430fc7c7b9aa233ec6af5dd821
Showing with 48 additions and 22 deletions.
  1. +1 −1 test/common.bash
  2. +28 −9 test/domains/domain-records.bats
  3. +13 −6 test/domains/master-domains.bats
  4. +6 −6 test/domains/slave-domains.bats
View
@@ -9,7 +9,7 @@ removeLinodes() {
}
removeDomains() {
local domain_ids="( $( linode-cli domains list --format "id" --text --no-headers ))"
local domain_ids="( $( linode-cli domains list --format "id" --text --no-headers ) )"
local id
for id in $domain_ids ; do
@@ -4,27 +4,46 @@ load '../test_helper/bats-support/load'
load '../test_helper/bats-assert/load'
load '../common'
export domainId=$(linode-cli domains list --format="id" --text --no-header)
@test "it should create a domain" {
export timestamp=$(date +%s)
run linode-cli domains create --type master --domain "$timestamp-example.com" --soa_email="pthiel@linode.com" --text --no-header
assert_success
}
@test "it should create a domain SRV record" {
run linode-cli domains records-create --protocol=tcp --type=SRV --port=23 --priority=4 --service=telnet --target=8.8.8.8 --weight=4 $domainId --text --no-header --delimiter=","
assert_success
assert_output --regexp "[0-9]+,SRV,_telnet.tcp._tcp,8.8.8.8,0,4,4"
}
@test "it should list domain records" {
@test "it should list the SRV record" {
run linode-cli domains records-list $domainId --text --no-header --delimiter=","
assert_success
assert_output --regexp "[0-9]+,SRV,_telnet.tcp._tcp,8.8.8.8,0,4,4"
}
@test "it should view domain record" {
recordId=$(linode-cli domains records-list $domainId --text --no-header --format="id")
run linode-cli domains records-view $domainId $recordId --text --no-header --delimiter=","
assert_success
assert_output --regexp "[0-9]+,SRV,_telnet.tcp._tcp,8.8.8.8,0,4,4"
}
@test "it should update a domain record" {
recordId=$(linode-cli domains records-list $domainId --text --no-header --format="id")
run linode-cli domains records-update $domainId $recordId --target="8.8.4.4" --text --no-header --delimiter=","
assert_success
assert_output --regexp "[0-9]+,SRV,_telnet.tcp._tcp,8.8.4.4,0,4,4"
}
@test "it should create a domain record" {
@test "it should delete a domain record" {
recordId=$(linode-cli domains records-list $domainId --text --no-header --format="id")
run linode-cli domains records-delete $domainId $recordId
assert_success
}
@test "it should delete a domain record" {
@test "it should delete all domains" {
run removeDomains
}
@@ -9,7 +9,7 @@ load '../common'
run linode-cli domains create --domain "$timestamp-example.com" --soa_email="pthiel+$timestamp@linode.com" --text --no-header
assert_failure
assert_output --partial "Request failed: 400"
assert_output --partial "type type is not valid"
assert_output --partial "type type is required"
}
@test "it should fail to create a master domain without a SOA email" {
@@ -27,16 +27,23 @@ load '../common'
assert_output --regexp "[0-9]+,$timestamp-example.com,master,active,pthiel\+$timestamp@linode.com"
}
@test "it should update the master domain" {
@test "it should update the master domain soa_email" {
newSoaEmail='pthiel@linode.com'
run linode-cli domains update $(linode-cli domains list --text --no-header --format="id") --soa_email $newSoaEmail --format="soa_email" --text --no-header
assert_success
assert_output --partial $newSoaEmail
}
@test "it should list domains" {
@test "it should list master domains" {
run linode-cli domains list --format="id,domain,type,status" --text --no-header --delimiter=","
assert_success
assert_output --regexp "[0-9]+,[0-9]+-example.com,master,active"
}
@test "it should show domain detail" {
run linode-cli domains view $(linode-cli domains list --text --no-header --format="id") --text --no-header --delimiter="," --format="id,domain,type,status,soa_email"
assert_success
assert_output --regexp "[0-9]+,[0-9]+-example.com,master,active"
}
@test "it should delete all slave domains" {
@@ -24,12 +24,12 @@ domainTimeStamp=0
assert_output --partial "$domainTimeStamp-example.com"
}
@test "it should fail to update domain without a type" {
slaveId=$(linode-cli domains list --domain "$domainTimeStamp-example.com" --format "id" --text --no-header)
run linode-cli domains update $slaveId --master_ips 8.8.8.8 --text --no-header --delimiter "," --format "id,domain,type,status"
assert_failure
# assert_output --partial
}
# @test "it should fail to update domain without a type" {
# slaveId=$(linode-cli domains list --domain "$domainTimeStamp-example.com" --format "id" --text --no-header)
# run linode-cli domains update $slaveId --master_ips 8.8.8.8 --text --no-header --deleteimiter "," --format "id,domain,type,status"
# assert_failure
# # assert_output --partial
# }
@test "it should update a slave domain" {
slaveId=$(linode-cli domains list --domain $domainTimeStamp-example.com --format "id" --text --no-header)

0 comments on commit aebceb9

Please sign in to comment.