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 IMPORTS
"github.com/hashicorp/terraform/plugin" "github.com/hashicorp/terraform/plugin"
"github.com/hashicorp/terraform/terraform" "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{ var InternalProviders = map[string]plugin.ProviderFunc{
@ -280,4 +283,10 @@ var InternalProvisioners = map[string]plugin.ProvisionerFunc{
PROVISIONERS 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", Package: "file",
PluginName: "file", PluginName: "file",
TypeName: "ResourceProvisioner", TypeName: "Provisioner",
Path: "builtin/provisioners/file", Path: "builtin/provisioners/file",
ImportName: "fileresourceprovisioner", ImportName: "fileprovisioner",
}, },
{ {
Package: "localexec", Package: "localexec",
PluginName: "local-exec", PluginName: "local-exec",
TypeName: "ResourceProvisioner", TypeName: "Provisioner",
Path: "builtin/provisioners/local-exec", Path: "builtin/provisioners/local-exec",
ImportName: "localexecresourceprovisioner", ImportName: "localexecprovisioner",
}, },
{ {
Package: "remoteexec", Package: "remoteexec",
PluginName: "remote-exec", PluginName: "remote-exec",
TypeName: "ResourceProvisioner", TypeName: "Provisioner",
Path: "builtin/provisioners/remote-exec", Path: "builtin/provisioners/remote-exec",
ImportName: "remoteexecresourceprovisioner", ImportName: "remoteexecprovisioner",
}, },
}) })
expected := ` "file": func() terraform.ResourceProvisioner { return new(fileresourceprovisioner.ResourceProvisioner) }, expected := ` "file": fileprovisioner.Provisioner,
"local-exec": func() terraform.ResourceProvisioner { return new(localexecresourceprovisioner.ResourceProvisioner) }, "local-exec": localexecprovisioner.Provisioner,
"remote-exec": func() terraform.ResourceProvisioner { return new(remoteexecresourceprovisioner.ResourceProvisioner) }, "remote-exec": remoteexecprovisioner.Provisioner,
` `
if p != expected { if p != expected {
@ -86,13 +86,10 @@ func TestDiscoverTypesProviders(t *testing.T) {
} }
func TestDiscoverTypesProvisioners(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 { if err != nil {
t.Fatalf(err.Error()) t.Fatalf(err.Error())
} }
if !contains(plugins, "chef") {
t.Errorf("Expected to find chef provisioner")
}
if !contains(plugins, "remote-exec") { if !contains(plugins, "remote-exec") {
t.Errorf("Expected to find remote-exec provisioner") t.Errorf("Expected to find remote-exec provisioner")
} }