builder/hyperone: Add tests for HCL syntax

This commit is contained in:
Adam Dobrawy 2020-05-19 01:21:00 +02:00
parent a3cba02c86
commit cc62fc9ebb
2 changed files with 37 additions and 1 deletions

View File

@ -18,7 +18,7 @@ USER_VARS="${USER_VARS} -var token=${HYPERONE_TOKEN}"
USER_VARS="${USER_VARS} -var project=${HYPERONE_PROJECT}" USER_VARS="${USER_VARS} -var project=${HYPERONE_PROJECT}"
hyperone_has_image() { hyperone_has_image() {
h1 image list --project-select=${HYPERONE_PROJECT} --query "[?tag.${2}=='${3}']" --output=tsv | grep $1 | wc -l h1 image list --project-select=${HYPERONE_PROJECT} --query "[?tag.${2}=='${3}']" --output=tsv | grep $1 -c
} }
teardown() { teardown() {
@ -34,6 +34,13 @@ teardown() {
[ "$(hyperone_has_image "packerbats-minimal" "key" "value")" -eq 1 ] [ "$(hyperone_has_image "packerbats-minimal" "key" "value")" -eq 1 ]
} }
@test "hyperone: build new-syntax.pkr.hcl" {
run packer build ${USER_VARS} $FIXTURE_ROOT/new-syntax.pkr.hcl
[ "$status" -eq 0 ]
[ "$(hyperone_has_image "packerbats-hcl" "key" "value")" -eq 1 ]
}
@test "hyperone: build chroot.json" { @test "hyperone: build chroot.json" {
run packer build ${USER_VARS} $FIXTURE_ROOT/chroot.json run packer build ${USER_VARS} $FIXTURE_ROOT/chroot.json
[ "$status" -eq 0 ] [ "$status" -eq 0 ]

View File

@ -0,0 +1,29 @@
variable "token" {
type = string
}
variable "project" {
type = string
}
source "hyperone" "new-syntax" {
token = var.token
project = var.project
source_image = "debian"
disk_size = 10
vm_type = "a1.nano"
image_name = "packerbats-hcl-{{timestamp}}"
image_tags = {
key="value"
}
}
build {
sources = [
"source.hyperone.new-syntax"
]
provisioner "shell" {
inline = ["sleep 5"]
}
}