@ -5892,98 +5892,6 @@ func TestContext2Apply_outputDiffVars(t *testing.T) {
}
}
func TestContext2Apply_Provisioner_ConnInfo ( t * testing . T ) {
m := testModule ( t , "apply-provisioner-conninfo" )
p := testProvider ( "aws" )
pr := testProvisioner ( )
p . ApplyFn = func ( info * InstanceInfo , s * InstanceState , d * InstanceDiff ) ( * InstanceState , error ) {
if s . Ephemeral . ConnInfo == nil {
t . Fatalf ( "ConnInfo not initialized" )
}
result , _ := testApplyFn ( info , s , d )
result . Ephemeral . ConnInfo = map [ string ] string {
"type" : "ssh" ,
"host" : "127.0.0.1" ,
"port" : "22" ,
}
return result , nil
}
p . DiffFn = testDiffFn
pr . GetSchemaResponse = provisioners . GetSchemaResponse {
Provisioner : & configschema . Block {
Attributes : map [ string ] * configschema . Attribute {
"foo" : { Type : cty . String , Optional : true } ,
} ,
} ,
}
pr . ApplyFn = func ( rs * InstanceState , c * ResourceConfig ) error {
conn := rs . Ephemeral . ConnInfo
if conn [ "type" ] != "telnet" {
t . Fatalf ( "Bad: %#v" , conn )
}
if conn [ "host" ] != "127.0.0.1" {
t . Fatalf ( "Bad: %#v" , conn )
}
if conn [ "port" ] != "2222" {
t . Fatalf ( "Bad: %#v" , conn )
}
if conn [ "user" ] != "superuser" {
t . Fatalf ( "Bad: %#v" , conn )
}
if conn [ "password" ] != "test" {
t . Fatalf ( "Bad: %#v" , conn )
}
return nil
}
ctx := testContext2 ( t , & ContextOpts {
Config : m ,
ProviderResolver : providers . ResolverFixed (
map [ string ] providers . Factory {
"aws" : testProviderFuncFixed ( p ) ,
} ,
) ,
Provisioners : map [ string ] ProvisionerFactory {
"shell" : testProvisionerFuncFixed ( pr ) ,
} ,
Variables : InputValues {
"value" : & InputValue {
Value : cty . StringVal ( "1" ) ,
SourceType : ValueFromCaller ,
} ,
"pass" : & InputValue {
Value : cty . StringVal ( "test" ) ,
SourceType : ValueFromCaller ,
} ,
} ,
} )
if _ , diags := ctx . Plan ( ) ; diags . HasErrors ( ) {
t . Fatalf ( "plan errors: %s" , diags . Err ( ) )
}
state , diags := ctx . Apply ( )
if diags . HasErrors ( ) {
t . Fatalf ( "diags: %s" , diags . Err ( ) )
}
actual := strings . TrimSpace ( state . String ( ) )
expected := strings . TrimSpace ( testTerraformApplyProvisionerStr )
if actual != expected {
t . Fatalf ( "wrong result\n\ngot:\n%s\n\nwant:\n%s" , actual , expected )
}
// Verify apply was invoked
if ! pr . ProvisionResourceCalled {
t . Fatalf ( "provisioner not invoked" )
}
}
func TestContext2Apply_destroyX ( t * testing . T ) {
m := testModule ( t , "apply-destroy" )
h := new ( HookRecordApplyOrder )