test: file provisioner tests pass

This commit is contained in:
Mitchell Hashimoto 2013-12-12 11:25:33 -08:00
parent 318ced9549
commit ca24c66491
6 changed files with 102 additions and 0 deletions

View File

@ -0,0 +1 @@
337 miles

View File

@ -0,0 +1,22 @@
{
"builders": [{
"type": "amazon-ebs",
"ami_name": "packer-test {{timestamp}}",
"instance_type": "m1.small",
"region": "us-east-1",
"ssh_username": "ubuntu",
"source_ami": "ami-0568456c",
"tags": {
"packer-test": "true"
}
}],
"provisioners": [{
"type": "file",
"source": "dir",
"destination": "/tmp"
}, {
"type": "shell",
"inline": ["cat /tmp/dir/file.txt"]
}]
}

View File

@ -0,0 +1,22 @@
{
"builders": [{
"type": "amazon-ebs",
"ami_name": "packer-test {{timestamp}}",
"instance_type": "m1.small",
"region": "us-east-1",
"ssh_username": "ubuntu",
"source_ami": "ami-0568456c",
"tags": {
"packer-test": "true"
}
}],
"provisioners": [{
"type": "file",
"source": "dir/",
"destination": "/tmp"
}, {
"type": "shell",
"inline": ["cat /tmp/file.txt"]
}]
}

View File

@ -0,0 +1,22 @@
{
"builders": [{
"type": "amazon-ebs",
"ami_name": "packer-test {{timestamp}}",
"instance_type": "m1.small",
"region": "us-east-1",
"ssh_username": "ubuntu",
"source_ami": "ami-0568456c",
"tags": {
"packer-test": "true"
}
}],
"provisioners": [{
"type": "file",
"source": "file.txt",
"destination": "/tmp/file.txt"
}, {
"type": "shell",
"inline": ["cat /tmp/file.txt"]
}]
}

View File

@ -0,0 +1 @@
24901 miles

34
test/provisioner_file.bats Executable file
View File

@ -0,0 +1,34 @@
#!/usr/bin/env bats
#
# This tests the amazon-ebs builder. The teardown function will automatically
# delete any AMIs with a tag of `packer-test` being equal to "true" so
# be sure any test cases set this.
load test_helper
fixtures provisioner-file
setup() {
cd $FIXTURE_ROOT
}
teardown() {
aws_ami_cleanup
}
@test "file provisioner: single file" {
run packer build $FIXTURE_ROOT/file.json
[ "$status" -eq 0 ]
[[ "$output" == *"24901 miles"* ]]
}
@test "file provisioner: directory (no trailing slash)" {
run packer build $FIXTURE_ROOT/dir_no_trailing.json
[ "$status" -eq 0 ]
[[ "$output" == *"337 miles"* ]]
}
@test "file provisioner: directory (with trailing slash)" {
run packer build $FIXTURE_ROOT/dir_with_trailing.json
[ "$status" -eq 0 ]
[[ "$output" == *"337 miles"* ]]
}