2013-10-05 22:29:02 -04:00
|
|
|
package vagrant
|
|
|
|
|
|
|
|
import (
|
2015-10-23 21:33:51 -04:00
|
|
|
"strings"
|
2013-10-05 22:29:02 -04:00
|
|
|
"testing"
|
2015-10-23 21:33:51 -04:00
|
|
|
|
2020-12-17 16:29:25 -05:00
|
|
|
packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
|
2013-10-05 22:29:02 -04:00
|
|
|
)
|
|
|
|
|
2013-12-19 16:41:48 -05:00
|
|
|
func TestDigitalOceanProvider_impl(t *testing.T) {
|
|
|
|
var _ Provider = new(DigitalOceanProvider)
|
2013-10-05 22:29:02 -04:00
|
|
|
}
|
2015-10-23 21:33:51 -04:00
|
|
|
|
|
|
|
func TestDigitalOceanProvider_KeepInputArtifact(t *testing.T) {
|
|
|
|
p := new(DigitalOceanProvider)
|
|
|
|
|
|
|
|
if !p.KeepInputArtifact() {
|
|
|
|
t.Fatal("should keep input artifact")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestDigitalOceanProvider_ArtifactId(t *testing.T) {
|
|
|
|
p := new(DigitalOceanProvider)
|
|
|
|
ui := testUi()
|
2020-11-20 13:21:29 -05:00
|
|
|
artifact := &packersdk.MockArtifact{
|
2015-10-23 21:33:51 -04:00
|
|
|
IdValue: "San Francisco:42",
|
|
|
|
}
|
|
|
|
|
|
|
|
vagrantfile, _, err := p.Process(ui, artifact, "foo")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("should not have error: %s", err)
|
|
|
|
}
|
|
|
|
image := `digital_ocean.image = "42"`
|
2017-03-28 21:40:46 -04:00
|
|
|
if !strings.Contains(vagrantfile, image) {
|
2015-10-23 21:33:51 -04:00
|
|
|
t.Fatalf("wrong image substitution: %s", vagrantfile)
|
|
|
|
}
|
|
|
|
region := `digital_ocean.region = "San Francisco"`
|
2017-03-28 21:40:46 -04:00
|
|
|
if !strings.Contains(vagrantfile, region) {
|
2015-10-23 21:33:51 -04:00
|
|
|
t.Fatalf("wrong region substitution: %s", vagrantfile)
|
|
|
|
}
|
|
|
|
}
|