scripts: update tests for generate plugins to pass new style

This commit is contained in:
Mitchell Hashimoto 2016-12-22 18:17:49 -08:00
parent 447a5c8b9e
commit cde458d74f
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
2 changed files with 19 additions and 13 deletions

View File

@ -270,6 +270,9 @@ import (
IMPORTS
"github.com/hashicorp/terraform/plugin"
"github.com/hashicorp/terraform/terraform"
// Legacy, will remove once it conforms with new structure
chefprovisioner "github.com/hashicorp/terraform/builtin/provisioners/chef"
)
var InternalProviders = map[string]plugin.ProviderFunc{
@ -280,4 +283,10 @@ var InternalProvisioners = map[string]plugin.ProvisionerFunc{
PROVISIONERS
}
func init() {
// Legacy provisioners that don't match our heuristics for auto-finding
// built-in provisioners.
InternalProvisioners["chef"] = func() terraform.ResourceProvisioner { return new(chefprovisioner.ResourceProvisioner) }
}
`

View File

@ -7,29 +7,29 @@ func TestMakeProvisionerMap(t *testing.T) {
{
Package: "file",
PluginName: "file",
TypeName: "ResourceProvisioner",
TypeName: "Provisioner",
Path: "builtin/provisioners/file",
ImportName: "fileresourceprovisioner",
ImportName: "fileprovisioner",
},
{
Package: "localexec",
PluginName: "local-exec",
TypeName: "ResourceProvisioner",
TypeName: "Provisioner",
Path: "builtin/provisioners/local-exec",
ImportName: "localexecresourceprovisioner",
ImportName: "localexecprovisioner",
},
{
Package: "remoteexec",
PluginName: "remote-exec",
TypeName: "ResourceProvisioner",
TypeName: "Provisioner",
Path: "builtin/provisioners/remote-exec",
ImportName: "remoteexecresourceprovisioner",
ImportName: "remoteexecprovisioner",
},
})
expected := ` "file": func() terraform.ResourceProvisioner { return new(fileresourceprovisioner.ResourceProvisioner) },
"local-exec": func() terraform.ResourceProvisioner { return new(localexecresourceprovisioner.ResourceProvisioner) },
"remote-exec": func() terraform.ResourceProvisioner { return new(remoteexecresourceprovisioner.ResourceProvisioner) },
expected := ` "file": fileprovisioner.Provisioner,
"local-exec": localexecprovisioner.Provisioner,
"remote-exec": remoteexecprovisioner.Provisioner,
`
if p != expected {
@ -86,13 +86,10 @@ func TestDiscoverTypesProviders(t *testing.T) {
}
func TestDiscoverTypesProvisioners(t *testing.T) {
plugins, err := discoverTypesInPath("../builtin/provisioners", "ResourceProvisioner", "")
plugins, err := discoverTypesInPath("../builtin/provisioners", "terraform.ResourceProvisioner", "Provisioner")
if err != nil {
t.Fatalf(err.Error())
}
if !contains(plugins, "chef") {
t.Errorf("Expected to find chef provisioner")
}
if !contains(plugins, "remote-exec") {
t.Errorf("Expected to find remote-exec provisioner")
}