@@ -430,7 +430,24 @@ func TestContextImport_providerConfigResources(t *testing.T) {
430430
431431func TestContextImport_refresh (t * testing.T ) {
432432 p := testProvider ("aws" )
433- m := testModule (t , "import-provider" )
433+ m := testModuleInline (t , map [string ]string {
434+ "main.tf" : `
435+ provider "aws" {
436+ foo = "bar"
437+ }
438+
439+ resource "aws_instance" "foo" {
440+ }
441+
442+
443+ // we are only importing aws_instance.foo, so these resources will be unknown
444+ resource "aws_instance" "bar" {
445+ }
446+ data "aws_data_source" "bar" {
447+ foo = aws_instance.bar.id
448+ }
449+ ` })
450+
434451 ctx := testContext2 (t , & ContextOpts {
435452 Providers : map [addrs.Provider ]providers.Factory {
436453 addrs .NewDefaultProvider ("aws" ): testProviderFuncFixed (p ),
@@ -448,6 +465,13 @@ func TestContextImport_refresh(t *testing.T) {
448465 },
449466 }
450467
468+ p .ReadDataSourceResponse = & providers.ReadDataSourceResponse {
469+ State : cty .ObjectVal (map [string ]cty.Value {
470+ "id" : cty .StringVal ("id" ),
471+ "foo" : cty .UnknownVal (cty .String ),
472+ }),
473+ }
474+
451475 p .ReadResourceFn = nil
452476
453477 p .ReadResourceResponse = & providers.ReadResourceResponse {
@@ -471,6 +495,10 @@ func TestContextImport_refresh(t *testing.T) {
471495 t .Fatalf ("unexpected errors: %s" , diags .Err ())
472496 }
473497
498+ if d := state .ResourceInstance (mustResourceInstanceAddr ("data.aws_data_source.bar" )); d != nil {
499+ t .Errorf ("data.aws_data_source.bar has a status of ObjectPlanned and should not be in the state\n got:%#v\n " , d .Current )
500+ }
501+
474502 actual := strings .TrimSpace (state .String ())
475503 expected := strings .TrimSpace (testImportRefreshStr )
476504 if actual != expected {
0 commit comments