From 58fe557a9fe1723f5990f45379ea2d573f24ebbc Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 30 Apr 2016 16:55:26 -0500 Subject: [PATCH] terraform: test that missing type results in error on import --- terraform/context_import_test.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/terraform/context_import_test.go b/terraform/context_import_test.go index 7fc133256..f55ba3f69 100644 --- a/terraform/context_import_test.go +++ b/terraform/context_import_test.go @@ -39,6 +39,33 @@ func TestContextImport_basic(t *testing.T) { } } +func TestContextImport_missingType(t *testing.T) { + p := testProvider("aws") + ctx := testContext2(t, &ContextOpts{ + Providers: map[string]ResourceProviderFactory{ + "aws": testProviderFuncFixed(p), + }, + }) + + p.ImportStateReturn = []*InstanceState{ + &InstanceState{ + ID: "foo", + }, + } + + _, err := ctx.Import(&ImportOpts{ + Targets: []*ImportTarget{ + &ImportTarget{ + Addr: "aws_instance.foo", + ID: "bar", + }, + }, + }) + if err == nil { + t.Fatal("should error") + } +} + func TestContextImport_refresh(t *testing.T) { p := testProvider("aws") ctx := testContext2(t, &ContextOpts{