2013-06-26 20:37:46 -04:00
|
|
|
package vagrant
|
|
|
|
|
|
|
|
import (
|
2015-10-23 21:33:51 -04:00
|
|
|
"strings"
|
2013-06-26 20:37:46 -04:00
|
|
|
"testing"
|
2015-10-23 21:33:51 -04:00
|
|
|
|
2020-11-20 13:21:29 -05:00
|
|
|
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
2013-06-26 20:37:46 -04:00
|
|
|
)
|
|
|
|
|
2013-12-19 16:37:09 -05:00
|
|
|
func TestAWSProvider_impl(t *testing.T) {
|
|
|
|
var _ Provider = new(AWSProvider)
|
2013-06-26 20:37:46 -04:00
|
|
|
}
|
2014-02-21 23:04:03 -05:00
|
|
|
|
|
|
|
func TestAWSProvider_KeepInputArtifact(t *testing.T) {
|
|
|
|
p := new(AWSProvider)
|
|
|
|
|
|
|
|
if !p.KeepInputArtifact() {
|
|
|
|
t.Fatal("should keep input artifact")
|
|
|
|
}
|
|
|
|
}
|
2015-10-23 21:33:51 -04:00
|
|
|
|
|
|
|
func TestAWSProvider_ArtifactId(t *testing.T) {
|
|
|
|
p := new(AWSProvider)
|
|
|
|
ui := testUi()
|
2020-11-20 13:21:29 -05:00
|
|
|
artifact := &packersdk.MockArtifact{
|
2015-10-23 21:33:51 -04:00
|
|
|
IdValue: "us-east-1:ami-1234",
|
|
|
|
}
|
|
|
|
|
|
|
|
vagrantfile, _, err := p.Process(ui, artifact, "foo")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("should not have error: %s", err)
|
|
|
|
}
|
|
|
|
result := `aws.region_config "us-east-1", ami: "ami-1234"`
|
2017-03-28 21:40:46 -04:00
|
|
|
if !strings.Contains(vagrantfile, result) {
|
2015-10-23 21:33:51 -04:00
|
|
|
t.Fatalf("wrong substitution: %s", vagrantfile)
|
|
|
|
}
|
|
|
|
}
|