remove legacy ApplyFn from mock provisioner
This commit is contained in:
parent
177797100d
commit
a0caed541d
File diff suppressed because it is too large
Load Diff
|
@ -48,8 +48,8 @@ func contextFixtureApplyVars(t *testing.T) *contextTestFixture {
|
|||
"map": {Type: cty.Map(cty.String), Optional: true},
|
||||
},
|
||||
})
|
||||
p.ApplyFn = testApplyFn
|
||||
p.DiffFn = testDiffFn
|
||||
p.ApplyResourceChangeFn = testApplyFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
return &contextTestFixture{
|
||||
Config: c,
|
||||
Providers: map[addrs.Provider]providers.Factory{
|
||||
|
@ -74,8 +74,8 @@ func contextFixtureApplyVarsEnv(t *testing.T) *contextTestFixture {
|
|||
"type": {Type: cty.String, Computed: true},
|
||||
},
|
||||
})
|
||||
p.ApplyFn = testApplyFn
|
||||
p.DiffFn = testDiffFn
|
||||
p.ApplyResourceChangeFn = testApplyFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
return &contextTestFixture{
|
||||
Config: c,
|
||||
Providers: map[addrs.Provider]providers.Factory{
|
||||
|
|
|
@ -17,8 +17,8 @@ import (
|
|||
func TestContext2Input_provider(t *testing.T) {
|
||||
m := testModule(t, "input-provider")
|
||||
p := testProvider("aws")
|
||||
p.ApplyFn = testApplyFn
|
||||
p.DiffFn = testDiffFn
|
||||
p.ApplyResourceChangeFn = testApplyFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
p.GetSchemaReturn = &ProviderSchema{
|
||||
Provider: &configschema.Block{
|
||||
Attributes: map[string]*configschema.Attribute{
|
||||
|
@ -89,8 +89,8 @@ func TestContext2Input_providerMulti(t *testing.T) {
|
|||
m := testModule(t, "input-provider-multi")
|
||||
|
||||
p := testProvider("aws")
|
||||
p.ApplyFn = testApplyFn
|
||||
p.DiffFn = testDiffFn
|
||||
p.ApplyResourceChangeFn = testApplyFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
p.GetSchemaReturn = &ProviderSchema{
|
||||
Provider: &configschema.Block{
|
||||
Attributes: map[string]*configschema.Attribute{
|
||||
|
@ -158,8 +158,8 @@ func TestContext2Input_providerMulti(t *testing.T) {
|
|||
func TestContext2Input_providerOnce(t *testing.T) {
|
||||
m := testModule(t, "input-provider-once")
|
||||
p := testProvider("aws")
|
||||
p.ApplyFn = testApplyFn
|
||||
p.DiffFn = testDiffFn
|
||||
p.ApplyResourceChangeFn = testApplyFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
Providers: map[addrs.Provider]providers.Factory{
|
||||
|
@ -178,8 +178,8 @@ func TestContext2Input_providerId(t *testing.T) {
|
|||
m := testModule(t, "input-provider")
|
||||
|
||||
p := testProvider("aws")
|
||||
p.ApplyFn = testApplyFn
|
||||
p.DiffFn = testDiffFn
|
||||
p.ApplyResourceChangeFn = testApplyFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
p.GetSchemaReturn = &ProviderSchema{
|
||||
Provider: &configschema.Block{
|
||||
Attributes: map[string]*configschema.Attribute{
|
||||
|
@ -243,8 +243,8 @@ func TestContext2Input_providerOnly(t *testing.T) {
|
|||
m := testModule(t, "input-provider-vars")
|
||||
|
||||
p := testProvider("aws")
|
||||
p.ApplyFn = testApplyFn
|
||||
p.DiffFn = testDiffFn
|
||||
p.ApplyResourceChangeFn = testApplyFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
p.GetSchemaReturn = &ProviderSchema{
|
||||
Provider: &configschema.Block{
|
||||
Attributes: map[string]*configschema.Attribute{
|
||||
|
@ -317,8 +317,8 @@ func TestContext2Input_providerVars(t *testing.T) {
|
|||
input := new(MockUIInput)
|
||||
m := testModule(t, "input-provider-with-vars")
|
||||
p := testProvider("aws")
|
||||
p.ApplyFn = testApplyFn
|
||||
p.DiffFn = testDiffFn
|
||||
p.ApplyResourceChangeFn = testApplyFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
Providers: map[addrs.Provider]providers.Factory{
|
||||
|
@ -363,8 +363,8 @@ func TestContext2Input_providerVarsModuleInherit(t *testing.T) {
|
|||
input := new(MockUIInput)
|
||||
m := testModule(t, "input-provider-with-vars-and-module")
|
||||
p := testProvider("aws")
|
||||
p.ApplyFn = testApplyFn
|
||||
p.DiffFn = testDiffFn
|
||||
p.ApplyResourceChangeFn = testApplyFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
Providers: map[addrs.Provider]providers.Factory{
|
||||
|
@ -383,8 +383,8 @@ func TestContext2Input_submoduleTriggersInvalidCount(t *testing.T) {
|
|||
input := new(MockUIInput)
|
||||
m := testModule(t, "input-submodule-count")
|
||||
p := testProvider("aws")
|
||||
p.ApplyFn = testApplyFn
|
||||
p.DiffFn = testDiffFn
|
||||
p.ApplyResourceChangeFn = testApplyFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
Providers: map[addrs.Provider]providers.Factory{
|
||||
|
|
|
@ -27,7 +27,7 @@ import (
|
|||
func TestContext2Plan_basic(t *testing.T) {
|
||||
m := testModule(t, "plan-good")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
Providers: map[addrs.Provider]providers.Factory{
|
||||
|
@ -83,7 +83,7 @@ func TestContext2Plan_basic(t *testing.T) {
|
|||
func TestContext2Plan_createBefore_deposed(t *testing.T) {
|
||||
m := testModule(t, "plan-cbd")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
state := states.NewState()
|
||||
root := state.EnsureModule(addrs.RootModuleInstance)
|
||||
|
@ -198,7 +198,7 @@ func TestContext2Plan_createBefore_deposed(t *testing.T) {
|
|||
func TestContext2Plan_createBefore_maintainRoot(t *testing.T) {
|
||||
m := testModule(t, "plan-cbd-maintain-root")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
Providers: map[addrs.Provider]providers.Factory{
|
||||
|
@ -230,7 +230,7 @@ func TestContext2Plan_createBefore_maintainRoot(t *testing.T) {
|
|||
func TestContext2Plan_emptyDiff(t *testing.T) {
|
||||
m := testModule(t, "plan-empty")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = func(req providers.PlanResourceChangeRequest) (resp providers.PlanResourceChangeResponse) {
|
||||
p.PlanResourceChangeFn = func(req providers.PlanResourceChangeRequest) (resp providers.PlanResourceChangeResponse) {
|
||||
resp.PlannedState = req.ProposedNewState
|
||||
return resp
|
||||
}
|
||||
|
@ -273,7 +273,7 @@ func TestContext2Plan_emptyDiff(t *testing.T) {
|
|||
func TestContext2Plan_escapedVar(t *testing.T) {
|
||||
m := testModule(t, "plan-escaped-var")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
Providers: map[addrs.Provider]providers.Factory{
|
||||
|
@ -315,7 +315,7 @@ func TestContext2Plan_escapedVar(t *testing.T) {
|
|||
func TestContext2Plan_minimal(t *testing.T) {
|
||||
m := testModule(t, "plan-empty")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
Providers: map[addrs.Provider]providers.Factory{
|
||||
|
@ -354,7 +354,7 @@ func TestContext2Plan_minimal(t *testing.T) {
|
|||
func TestContext2Plan_modules(t *testing.T) {
|
||||
m := testModule(t, "plan-modules")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
Providers: map[addrs.Provider]providers.Factory{
|
||||
|
@ -414,7 +414,7 @@ func TestContext2Plan_moduleExpand(t *testing.T) {
|
|||
// Test a smattering of plan expansion behavior
|
||||
m := testModule(t, "plan-modules-expand")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
Providers: map[addrs.Provider]providers.Factory{
|
||||
|
@ -475,7 +475,7 @@ func TestContext2Plan_moduleCycle(t *testing.T) {
|
|||
},
|
||||
},
|
||||
}
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
|
@ -530,7 +530,7 @@ func TestContext2Plan_moduleDeadlock(t *testing.T) {
|
|||
testCheckDeadlock(t, func() {
|
||||
m := testModule(t, "plan-module-deadlock")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
|
@ -576,7 +576,7 @@ func TestContext2Plan_moduleDeadlock(t *testing.T) {
|
|||
func TestContext2Plan_moduleInput(t *testing.T) {
|
||||
m := testModule(t, "plan-module-input")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
Providers: map[addrs.Provider]providers.Factory{
|
||||
|
@ -631,7 +631,7 @@ func TestContext2Plan_moduleInput(t *testing.T) {
|
|||
func TestContext2Plan_moduleInputComputed(t *testing.T) {
|
||||
m := testModule(t, "plan-module-input-computed")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
Providers: map[addrs.Provider]providers.Factory{
|
||||
|
@ -683,7 +683,7 @@ func TestContext2Plan_moduleInputComputed(t *testing.T) {
|
|||
func TestContext2Plan_moduleInputFromVar(t *testing.T) {
|
||||
m := testModule(t, "plan-module-input-var")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
Providers: map[addrs.Provider]providers.Factory{
|
||||
|
@ -751,7 +751,7 @@ func TestContext2Plan_moduleMultiVar(t *testing.T) {
|
|||
},
|
||||
},
|
||||
}
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
|
@ -815,7 +815,7 @@ func TestContext2Plan_moduleMultiVar(t *testing.T) {
|
|||
func TestContext2Plan_moduleOrphans(t *testing.T) {
|
||||
m := testModule(t, "plan-modules-remove")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
state := states.NewState()
|
||||
child := state.EnsureModule(addrs.RootModuleInstance.Child("child", addrs.NoKey))
|
||||
|
@ -889,7 +889,7 @@ func TestContext2Plan_moduleOrphansWithProvisioner(t *testing.T) {
|
|||
m := testModule(t, "plan-modules-remove-provisioners")
|
||||
p := testProvider("aws")
|
||||
pr := testProvisioner()
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
state := states.NewState()
|
||||
root := state.EnsureModule(addrs.RootModuleInstance)
|
||||
|
@ -1024,7 +1024,7 @@ func TestContext2Plan_moduleProviderInherit(t *testing.T) {
|
|||
|
||||
return
|
||||
}
|
||||
p.DiffFn = func(req providers.PlanResourceChangeRequest) (resp providers.PlanResourceChangeResponse) {
|
||||
p.PlanResourceChangeFn = func(req providers.PlanResourceChangeRequest) (resp providers.PlanResourceChangeResponse) {
|
||||
from := req.Config.GetAttr("from").AsString()
|
||||
|
||||
l.Lock()
|
||||
|
@ -1089,7 +1089,7 @@ func TestContext2Plan_moduleProviderInheritDeep(t *testing.T) {
|
|||
return
|
||||
}
|
||||
|
||||
p.DiffFn = func(req providers.PlanResourceChangeRequest) (resp providers.PlanResourceChangeResponse) {
|
||||
p.PlanResourceChangeFn = func(req providers.PlanResourceChangeRequest) (resp providers.PlanResourceChangeResponse) {
|
||||
if from != "root" {
|
||||
resp.Diagnostics = resp.Diagnostics.Append(fmt.Errorf("bad resource"))
|
||||
return
|
||||
|
@ -1153,7 +1153,7 @@ func TestContext2Plan_moduleProviderDefaultsVar(t *testing.T) {
|
|||
return
|
||||
}
|
||||
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
return p, nil
|
||||
},
|
||||
},
|
||||
|
@ -1197,7 +1197,7 @@ func TestContext2Plan_moduleProviderVar(t *testing.T) {
|
|||
},
|
||||
},
|
||||
}
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
|
@ -1241,7 +1241,7 @@ func TestContext2Plan_moduleProviderVar(t *testing.T) {
|
|||
func TestContext2Plan_moduleVar(t *testing.T) {
|
||||
m := testModule(t, "plan-module-var")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
Providers: map[addrs.Provider]providers.Factory{
|
||||
|
@ -1296,7 +1296,7 @@ func TestContext2Plan_moduleVar(t *testing.T) {
|
|||
func TestContext2Plan_moduleVarWrongTypeBasic(t *testing.T) {
|
||||
m := testModule(t, "plan-module-wrong-var-type")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
Providers: map[addrs.Provider]providers.Factory{
|
||||
|
@ -1313,7 +1313,7 @@ func TestContext2Plan_moduleVarWrongTypeBasic(t *testing.T) {
|
|||
func TestContext2Plan_moduleVarWrongTypeNested(t *testing.T) {
|
||||
m := testModule(t, "plan-module-wrong-var-type-nested")
|
||||
p := testProvider("null")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
Providers: map[addrs.Provider]providers.Factory{
|
||||
|
@ -1330,7 +1330,7 @@ func TestContext2Plan_moduleVarWrongTypeNested(t *testing.T) {
|
|||
func TestContext2Plan_moduleVarWithDefaultValue(t *testing.T) {
|
||||
m := testModule(t, "plan-module-var-with-default-value")
|
||||
p := testProvider("null")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
Providers: map[addrs.Provider]providers.Factory{
|
||||
|
@ -1347,7 +1347,7 @@ func TestContext2Plan_moduleVarWithDefaultValue(t *testing.T) {
|
|||
func TestContext2Plan_moduleVarComputed(t *testing.T) {
|
||||
m := testModule(t, "plan-module-var-computed")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
Providers: map[addrs.Provider]providers.Factory{
|
||||
|
@ -1398,7 +1398,7 @@ func TestContext2Plan_moduleVarComputed(t *testing.T) {
|
|||
func TestContext2Plan_preventDestroy_bad(t *testing.T) {
|
||||
m := testModule(t, "plan-prevent-destroy-bad")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
state := states.NewState()
|
||||
root := state.EnsureModule(addrs.RootModuleInstance)
|
||||
root.SetResourceInstanceCurrent(
|
||||
|
@ -1432,7 +1432,7 @@ func TestContext2Plan_preventDestroy_bad(t *testing.T) {
|
|||
func TestContext2Plan_preventDestroy_good(t *testing.T) {
|
||||
m := testModule(t, "plan-prevent-destroy-good")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
state := states.NewState()
|
||||
root := state.EnsureModule(addrs.RootModuleInstance)
|
||||
|
@ -1466,7 +1466,7 @@ func TestContext2Plan_preventDestroy_good(t *testing.T) {
|
|||
func TestContext2Plan_preventDestroy_countBad(t *testing.T) {
|
||||
m := testModule(t, "plan-prevent-destroy-count-bad")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
state := states.NewState()
|
||||
root := state.EnsureModule(addrs.RootModuleInstance)
|
||||
|
@ -1519,7 +1519,7 @@ func TestContext2Plan_preventDestroy_countGood(t *testing.T) {
|
|||
},
|
||||
},
|
||||
}
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
state := states.NewState()
|
||||
root := state.EnsureModule(addrs.RootModuleInstance)
|
||||
|
@ -1572,7 +1572,7 @@ func TestContext2Plan_preventDestroy_countGoodNoChange(t *testing.T) {
|
|||
},
|
||||
},
|
||||
}
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
state := states.NewState()
|
||||
root := state.EnsureModule(addrs.RootModuleInstance)
|
||||
|
@ -1606,7 +1606,7 @@ func TestContext2Plan_preventDestroy_countGoodNoChange(t *testing.T) {
|
|||
func TestContext2Plan_preventDestroy_destroyPlan(t *testing.T) {
|
||||
m := testModule(t, "plan-prevent-destroy-good")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
state := states.NewState()
|
||||
root := state.EnsureModule(addrs.RootModuleInstance)
|
||||
|
@ -1642,7 +1642,7 @@ func TestContext2Plan_preventDestroy_destroyPlan(t *testing.T) {
|
|||
func TestContext2Plan_provisionerCycle(t *testing.T) {
|
||||
m := testModule(t, "plan-provisioner-cycle")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
pr := testProvisioner()
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
|
@ -1663,7 +1663,7 @@ func TestContext2Plan_provisionerCycle(t *testing.T) {
|
|||
func TestContext2Plan_computed(t *testing.T) {
|
||||
m := testModule(t, "plan-computed")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
Providers: map[addrs.Provider]providers.Factory{
|
||||
|
@ -1806,7 +1806,7 @@ func TestContext2Plan_computedDataResource(t *testing.T) {
|
|||
},
|
||||
},
|
||||
}
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
|
@ -1866,7 +1866,7 @@ func TestContext2Plan_computedInFunction(t *testing.T) {
|
|||
},
|
||||
},
|
||||
}
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
p.ReadDataSourceResponse = providers.ReadDataSourceResponse{
|
||||
State: cty.ObjectVal(map[string]cty.Value{
|
||||
"computed": cty.ListVal([]cty.Value{
|
||||
|
@ -1914,7 +1914,7 @@ func TestContext2Plan_computedDataCountResource(t *testing.T) {
|
|||
},
|
||||
},
|
||||
}
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
|
@ -1945,7 +1945,7 @@ func TestContext2Plan_computedDataCountResource(t *testing.T) {
|
|||
func TestContext2Plan_localValueCount(t *testing.T) {
|
||||
m := testModule(t, "plan-local-value-count")
|
||||
p := testProvider("test")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
Providers: map[addrs.Provider]providers.Factory{
|
||||
|
@ -2081,7 +2081,7 @@ func TestContext2Plan_computedList(t *testing.T) {
|
|||
},
|
||||
},
|
||||
}
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
|
@ -2133,7 +2133,7 @@ func TestContext2Plan_computedList(t *testing.T) {
|
|||
func TestContext2Plan_computedMultiIndex(t *testing.T) {
|
||||
m := testModule(t, "plan-computed-multi-index")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
p.GetSchemaReturn = &ProviderSchema{
|
||||
ResourceTypes: map[string]*configschema.Block{
|
||||
|
@ -2147,7 +2147,7 @@ func TestContext2Plan_computedMultiIndex(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
|
@ -2203,7 +2203,7 @@ func TestContext2Plan_computedMultiIndex(t *testing.T) {
|
|||
func TestContext2Plan_count(t *testing.T) {
|
||||
m := testModule(t, "plan-count")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
Providers: map[addrs.Provider]providers.Factory{
|
||||
|
@ -2278,7 +2278,7 @@ func TestContext2Plan_count(t *testing.T) {
|
|||
func TestContext2Plan_countComputed(t *testing.T) {
|
||||
m := testModule(t, "plan-count-computed")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
Providers: map[addrs.Provider]providers.Factory{
|
||||
|
@ -2295,7 +2295,7 @@ func TestContext2Plan_countComputed(t *testing.T) {
|
|||
func TestContext2Plan_countComputedModule(t *testing.T) {
|
||||
m := testModule(t, "plan-count-computed-module")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
Providers: map[addrs.Provider]providers.Factory{
|
||||
|
@ -2315,7 +2315,7 @@ func TestContext2Plan_countComputedModule(t *testing.T) {
|
|||
func TestContext2Plan_countModuleStatic(t *testing.T) {
|
||||
m := testModule(t, "plan-count-module-static")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
Providers: map[addrs.Provider]providers.Factory{
|
||||
|
@ -2369,7 +2369,7 @@ func TestContext2Plan_countModuleStatic(t *testing.T) {
|
|||
func TestContext2Plan_countModuleStaticGrandchild(t *testing.T) {
|
||||
m := testModule(t, "plan-count-module-static-grandchild")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
Providers: map[addrs.Provider]providers.Factory{
|
||||
|
@ -2423,7 +2423,7 @@ func TestContext2Plan_countModuleStaticGrandchild(t *testing.T) {
|
|||
func TestContext2Plan_countIndex(t *testing.T) {
|
||||
m := testModule(t, "plan-count-index")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
Providers: map[addrs.Provider]providers.Factory{
|
||||
|
@ -2474,7 +2474,7 @@ func TestContext2Plan_countIndex(t *testing.T) {
|
|||
func TestContext2Plan_countVar(t *testing.T) {
|
||||
m := testModule(t, "plan-count-var")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
Providers: map[addrs.Provider]providers.Factory{
|
||||
|
@ -2599,7 +2599,7 @@ func TestContext2Plan_countZero(t *testing.T) {
|
|||
func TestContext2Plan_countOneIndex(t *testing.T) {
|
||||
m := testModule(t, "plan-count-one-index")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
Providers: map[addrs.Provider]providers.Factory{
|
||||
|
@ -2650,7 +2650,7 @@ func TestContext2Plan_countOneIndex(t *testing.T) {
|
|||
func TestContext2Plan_countDecreaseToOne(t *testing.T) {
|
||||
m := testModule(t, "plan-count-dec")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
state := states.NewState()
|
||||
root := state.EnsureModule(addrs.RootModuleInstance)
|
||||
|
@ -2752,7 +2752,7 @@ aws_instance.foo.2:
|
|||
func TestContext2Plan_countIncreaseFromNotSet(t *testing.T) {
|
||||
m := testModule(t, "plan-count-inc")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
state := states.NewState()
|
||||
root := state.EnsureModule(addrs.RootModuleInstance)
|
||||
|
@ -2832,7 +2832,7 @@ func TestContext2Plan_countIncreaseFromNotSet(t *testing.T) {
|
|||
func TestContext2Plan_countIncreaseFromOne(t *testing.T) {
|
||||
m := testModule(t, "plan-count-inc")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
state := states.NewState()
|
||||
root := state.EnsureModule(addrs.RootModuleInstance)
|
||||
root.SetResourceInstanceCurrent(
|
||||
|
@ -2916,7 +2916,7 @@ func TestContext2Plan_countIncreaseFromOne(t *testing.T) {
|
|||
func TestContext2Plan_countIncreaseFromOneCorrupted(t *testing.T) {
|
||||
m := testModule(t, "plan-count-inc")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
state := states.NewState()
|
||||
root := state.EnsureModule(addrs.RootModuleInstance)
|
||||
|
@ -3027,7 +3027,7 @@ func TestContext2Plan_countIncreaseWithSplatReference(t *testing.T) {
|
|||
},
|
||||
},
|
||||
}
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
state := states.NewState()
|
||||
root := state.EnsureModule(addrs.RootModuleInstance)
|
||||
|
@ -3120,7 +3120,7 @@ func TestContext2Plan_countIncreaseWithSplatReference(t *testing.T) {
|
|||
func TestContext2Plan_forEach(t *testing.T) {
|
||||
m := testModule(t, "plan-for-each")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
Providers: map[addrs.Provider]providers.Factory{
|
||||
|
@ -3156,7 +3156,7 @@ func TestContext2Plan_forEachUnknownValue(t *testing.T) {
|
|||
// expect this to produce an error, but not to panic.
|
||||
m := testModule(t, "plan-for-each-unknown-value")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
Providers: map[addrs.Provider]providers.Factory{
|
||||
|
@ -3187,7 +3187,7 @@ func TestContext2Plan_forEachUnknownValue(t *testing.T) {
|
|||
func TestContext2Plan_destroy(t *testing.T) {
|
||||
m := testModule(t, "plan-destroy")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
state := states.NewState()
|
||||
root := state.EnsureModule(addrs.RootModuleInstance)
|
||||
|
@ -3250,7 +3250,7 @@ func TestContext2Plan_destroy(t *testing.T) {
|
|||
func TestContext2Plan_moduleDestroy(t *testing.T) {
|
||||
m := testModule(t, "plan-module-destroy")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
state := states.NewState()
|
||||
root := state.EnsureModule(addrs.RootModuleInstance)
|
||||
|
@ -3314,7 +3314,7 @@ func TestContext2Plan_moduleDestroy(t *testing.T) {
|
|||
func TestContext2Plan_moduleDestroyCycle(t *testing.T) {
|
||||
m := testModule(t, "plan-module-destroy-gh-1835")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
state := states.NewState()
|
||||
aModule := state.EnsureModule(addrs.RootModuleInstance.Child("a_module", addrs.NoKey))
|
||||
|
@ -3378,7 +3378,7 @@ func TestContext2Plan_moduleDestroyCycle(t *testing.T) {
|
|||
func TestContext2Plan_moduleDestroyMultivar(t *testing.T) {
|
||||
m := testModule(t, "plan-module-destroy-multivar")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
state := states.NewState()
|
||||
child := state.EnsureModule(addrs.RootModuleInstance.Child("child", addrs.NoKey))
|
||||
|
@ -3457,7 +3457,7 @@ func TestContext2Plan_pathVar(t *testing.T) {
|
|||
},
|
||||
},
|
||||
}
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
|
@ -3522,7 +3522,7 @@ func TestContext2Plan_diffVar(t *testing.T) {
|
|||
State: state,
|
||||
})
|
||||
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
plan, diags := ctx.Plan()
|
||||
if diags.HasErrors() {
|
||||
|
@ -3576,7 +3576,7 @@ func TestContext2Plan_hook(t *testing.T) {
|
|||
m := testModule(t, "plan-good")
|
||||
h := new(MockHook)
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
Hooks: []Hook{h},
|
||||
|
@ -3604,7 +3604,7 @@ func TestContext2Plan_closeProvider(t *testing.T) {
|
|||
// "provider.aws".
|
||||
m := testModule(t, "plan-close-module-provider")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
Providers: map[addrs.Provider]providers.Factory{
|
||||
|
@ -3625,7 +3625,7 @@ func TestContext2Plan_closeProvider(t *testing.T) {
|
|||
func TestContext2Plan_orphan(t *testing.T) {
|
||||
m := testModule(t, "plan-orphan")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
state := states.NewState()
|
||||
root := state.EnsureModule(addrs.RootModuleInstance)
|
||||
root.SetResourceInstanceCurrent(
|
||||
|
@ -3688,7 +3688,7 @@ func TestContext2Plan_orphan(t *testing.T) {
|
|||
func TestContext2Plan_shadowUuid(t *testing.T) {
|
||||
m := testModule(t, "plan-shadow-uuid")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
Providers: map[addrs.Provider]providers.Factory{
|
||||
|
@ -3705,7 +3705,7 @@ func TestContext2Plan_shadowUuid(t *testing.T) {
|
|||
func TestContext2Plan_state(t *testing.T) {
|
||||
m := testModule(t, "plan-good")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
state := states.NewState()
|
||||
root := state.EnsureModule(addrs.RootModuleInstance)
|
||||
root.SetResourceInstanceCurrent(
|
||||
|
@ -3778,7 +3778,7 @@ func TestContext2Plan_state(t *testing.T) {
|
|||
func TestContext2Plan_taint(t *testing.T) {
|
||||
m := testModule(t, "plan-taint")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
state := states.NewState()
|
||||
root := state.EnsureModule(addrs.RootModuleInstance)
|
||||
root.SetResourceInstanceCurrent(
|
||||
|
@ -3858,8 +3858,8 @@ func TestContext2Plan_taintIgnoreChanges(t *testing.T) {
|
|||
},
|
||||
},
|
||||
}
|
||||
p.ApplyFn = testApplyFn
|
||||
p.DiffFn = testDiffFn
|
||||
p.ApplyResourceChangeFn = testApplyFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
state := states.NewState()
|
||||
root := state.EnsureModule(addrs.RootModuleInstance)
|
||||
|
@ -3923,7 +3923,7 @@ func TestContext2Plan_taintIgnoreChanges(t *testing.T) {
|
|||
func TestContext2Plan_taintDestroyInterpolatedCountRace(t *testing.T) {
|
||||
m := testModule(t, "plan-taint-interpolated-count")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
state := states.NewState()
|
||||
root := state.EnsureModule(addrs.RootModuleInstance)
|
||||
root.SetResourceInstanceCurrent(
|
||||
|
@ -4005,7 +4005,7 @@ func TestContext2Plan_taintDestroyInterpolatedCountRace(t *testing.T) {
|
|||
func TestContext2Plan_targeted(t *testing.T) {
|
||||
m := testModule(t, "plan-targeted")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
Providers: map[addrs.Provider]providers.Factory{
|
||||
|
@ -4056,7 +4056,7 @@ func TestContext2Plan_targeted(t *testing.T) {
|
|||
func TestContext2Plan_targetedCrossModule(t *testing.T) {
|
||||
m := testModule(t, "plan-targeted-cross-module")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
Providers: map[addrs.Provider]providers.Factory{
|
||||
|
@ -4120,7 +4120,7 @@ func TestContext2Plan_targetedModuleWithProvider(t *testing.T) {
|
|||
},
|
||||
},
|
||||
}
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
|
@ -4158,7 +4158,7 @@ func TestContext2Plan_targetedModuleWithProvider(t *testing.T) {
|
|||
func TestContext2Plan_targetedOrphan(t *testing.T) {
|
||||
m := testModule(t, "plan-targeted-orphan")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
state := states.NewState()
|
||||
root := state.EnsureModule(addrs.RootModuleInstance)
|
||||
|
@ -4226,7 +4226,7 @@ func TestContext2Plan_targetedOrphan(t *testing.T) {
|
|||
func TestContext2Plan_targetedModuleOrphan(t *testing.T) {
|
||||
m := testModule(t, "plan-targeted-module-orphan")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
state := states.NewState()
|
||||
child := state.EnsureModule(addrs.RootModuleInstance.Child("child", addrs.NoKey))
|
||||
|
@ -4290,7 +4290,7 @@ func TestContext2Plan_targetedModuleOrphan(t *testing.T) {
|
|||
func TestContext2Plan_targetedModuleUntargetedVariable(t *testing.T) {
|
||||
m := testModule(t, "plan-targeted-module-untargeted-variable")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
Providers: map[addrs.Provider]providers.Factory{
|
||||
|
@ -4347,7 +4347,7 @@ func TestContext2Plan_targetedModuleUntargetedVariable(t *testing.T) {
|
|||
func TestContext2Plan_outputContainsTargetedResource(t *testing.T) {
|
||||
m := testModule(t, "plan-untargeted-resource-output")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
Providers: map[addrs.Provider]providers.Factory{
|
||||
|
@ -4379,7 +4379,7 @@ func TestContext2Plan_outputContainsTargetedResource(t *testing.T) {
|
|||
func TestContext2Plan_targetedOverTen(t *testing.T) {
|
||||
m := testModule(t, "plan-targeted-over-ten")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
state := states.NewState()
|
||||
root := state.EnsureModule(addrs.RootModuleInstance)
|
||||
|
@ -4435,7 +4435,7 @@ func TestContext2Plan_targetedOverTen(t *testing.T) {
|
|||
func TestContext2Plan_provider(t *testing.T) {
|
||||
m := testModule(t, "plan-provider")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
var value interface{}
|
||||
p.ConfigureFn = func(req providers.ConfigureRequest) (resp providers.ConfigureResponse) {
|
||||
|
@ -4485,7 +4485,7 @@ func TestContext2Plan_varListErr(t *testing.T) {
|
|||
func TestContext2Plan_ignoreChanges(t *testing.T) {
|
||||
m := testModule(t, "plan-ignore-changes")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
state := states.NewState()
|
||||
root := state.EnsureModule(addrs.RootModuleInstance)
|
||||
|
@ -4544,7 +4544,7 @@ func TestContext2Plan_ignoreChanges(t *testing.T) {
|
|||
func TestContext2Plan_ignoreChangesWildcard(t *testing.T) {
|
||||
m := testModule(t, "plan-ignore-changes-wildcard")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
state := states.NewState()
|
||||
root := state.EnsureModule(addrs.RootModuleInstance)
|
||||
|
@ -4605,7 +4605,7 @@ func TestContext2Plan_ignoreChangesInMap(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
s := states.BuildState(func(ss *states.SyncState) {
|
||||
ss.SetResourceInstanceCurrent(
|
||||
|
@ -4680,8 +4680,8 @@ func TestContext2Plan_moduleMapLiteral(t *testing.T) {
|
|||
},
|
||||
},
|
||||
}
|
||||
p.ApplyFn = testApplyFn
|
||||
p.DiffFn = func(req providers.PlanResourceChangeRequest) (resp providers.PlanResourceChangeResponse) {
|
||||
p.ApplyResourceChangeFn = testApplyFn
|
||||
p.PlanResourceChangeFn = func(req providers.PlanResourceChangeRequest) (resp providers.PlanResourceChangeResponse) {
|
||||
s := req.ProposedNewState.AsValueMap()
|
||||
m := s["tags"].AsValueMap()
|
||||
|
||||
|
@ -4725,8 +4725,8 @@ func TestContext2Plan_computedValueInMap(t *testing.T) {
|
|||
},
|
||||
},
|
||||
}
|
||||
p.DiffFn = testDiffFn
|
||||
p.DiffFn = func(req providers.PlanResourceChangeRequest) (resp providers.PlanResourceChangeResponse) {
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
p.PlanResourceChangeFn = func(req providers.PlanResourceChangeRequest) (resp providers.PlanResourceChangeResponse) {
|
||||
resp = testDiffFn(req)
|
||||
|
||||
if req.TypeName != "aws_computed_source" {
|
||||
|
@ -4785,7 +4785,7 @@ func TestContext2Plan_computedValueInMap(t *testing.T) {
|
|||
func TestContext2Plan_moduleVariableFromSplat(t *testing.T) {
|
||||
m := testModule(t, "plan-module-variable-from-splat")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
p.GetSchemaReturn = &ProviderSchema{
|
||||
ResourceTypes: map[string]*configschema.Block{
|
||||
"aws_instance": {
|
||||
|
@ -4945,8 +4945,8 @@ func TestContext2Plan_createBeforeDestroy_depends_datasource(t *testing.T) {
|
|||
func TestContext2Plan_listOrder(t *testing.T) {
|
||||
m := testModule(t, "plan-list-order")
|
||||
p := testProvider("aws")
|
||||
p.ApplyFn = testApplyFn
|
||||
p.DiffFn = testDiffFn
|
||||
p.ApplyResourceChangeFn = testApplyFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
p.GetSchemaReturn = &ProviderSchema{
|
||||
ResourceTypes: map[string]*configschema.Block{
|
||||
"aws_instance": {
|
||||
|
@ -4992,7 +4992,7 @@ func TestContext2Plan_listOrder(t *testing.T) {
|
|||
func TestContext2Plan_ignoreChangesWithFlatmaps(t *testing.T) {
|
||||
m := testModule(t, "plan-ignore-changes-with-flatmaps")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
p.GetSchemaReturn = &ProviderSchema{
|
||||
ResourceTypes: map[string]*configschema.Block{
|
||||
"aws_instance": {
|
||||
|
@ -5081,7 +5081,7 @@ func TestContext2Plan_ignoreChangesWithFlatmaps(t *testing.T) {
|
|||
func TestContext2Plan_resourceNestedCount(t *testing.T) {
|
||||
m := testModule(t, "nested-resource-count-plan")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
p.ReadResourceFn = func(req providers.ReadResourceRequest) providers.ReadResourceResponse {
|
||||
return providers.ReadResourceResponse{
|
||||
NewState: req.PriorState,
|
||||
|
@ -5176,7 +5176,7 @@ func TestContext2Plan_resourceNestedCount(t *testing.T) {
|
|||
func TestContext2Plan_computedAttrRefTypeMismatch(t *testing.T) {
|
||||
m := testModule(t, "plan-computed-attr-ref-type-mismatch")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
p.ValidateResourceTypeConfigFn = func(req providers.ValidateResourceTypeConfigRequest) providers.ValidateResourceTypeConfigResponse {
|
||||
var diags tfdiags.Diagnostics
|
||||
if req.TypeName == "aws_instance" {
|
||||
|
@ -5189,8 +5189,8 @@ func TestContext2Plan_computedAttrRefTypeMismatch(t *testing.T) {
|
|||
Diagnostics: diags,
|
||||
}
|
||||
}
|
||||
p.DiffFn = testDiffFn
|
||||
p.ApplyFn = func(req providers.ApplyResourceChangeRequest) (resp providers.ApplyResourceChangeResponse) {
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
p.ApplyResourceChangeFn = func(req providers.ApplyResourceChangeRequest) (resp providers.ApplyResourceChangeResponse) {
|
||||
if req.TypeName != "aws_ami_list" {
|
||||
t.Fatalf("Reached apply for unexpected resource type! %s", req.TypeName)
|
||||
}
|
||||
|
@ -5618,7 +5618,7 @@ func TestContext2Plan_requiredModuleOutput(t *testing.T) {
|
|||
},
|
||||
},
|
||||
}
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
|
@ -5683,7 +5683,7 @@ func TestContext2Plan_requiredModuleObject(t *testing.T) {
|
|||
},
|
||||
},
|
||||
}
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
|
@ -5768,7 +5768,7 @@ resource "aws_instance" "foo" {
|
|||
)
|
||||
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
Providers: map[addrs.Provider]providers.Factory{
|
||||
|
@ -5830,7 +5830,7 @@ output"out" {
|
|||
})
|
||||
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
Providers: map[addrs.Provider]providers.Factory{
|
||||
|
@ -5860,7 +5860,7 @@ resource "aws_instance" "foo" {
|
|||
})
|
||||
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
targets := []addrs.Targetable{}
|
||||
target, diags := addrs.ParseTargetStr("module.mod[1].aws_instance.foo[0]")
|
||||
|
@ -5924,7 +5924,7 @@ resource "aws_instance" "foo" {
|
|||
})
|
||||
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
target, diags := addrs.ParseTargetStr("module.mod[1].aws_instance.foo")
|
||||
if diags.HasErrors() {
|
||||
|
@ -5994,7 +5994,7 @@ resource "aws_instance" "foo" {
|
|||
})
|
||||
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
|
@ -6075,8 +6075,8 @@ data "test_data_source" "foo" {}
|
|||
// for_each can reference a resource with 0 instances
|
||||
func TestContext2Plan_scaleInForEach(t *testing.T) {
|
||||
p := testProvider("test")
|
||||
p.ApplyFn = testApplyFn
|
||||
p.DiffFn = testDiffFn
|
||||
p.ApplyResourceChangeFn = testApplyFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
m := testModuleInline(t, map[string]string{
|
||||
"main.tf": `
|
||||
|
@ -6129,7 +6129,7 @@ resource "test_instance" "b" {
|
|||
func TestContext2Plan_targetedModuleInstance(t *testing.T) {
|
||||
m := testModule(t, "plan-targeted")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
Providers: map[addrs.Provider]providers.Factory{
|
||||
|
@ -6212,8 +6212,8 @@ data "test_data_source" "d" {
|
|||
|
||||
func TestContext2Plan_dataReferencesResource(t *testing.T) {
|
||||
p := testProvider("test")
|
||||
p.ApplyFn = testApplyFn
|
||||
p.DiffFn = testDiffFn
|
||||
p.ApplyResourceChangeFn = testApplyFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
p.ReadDataSourceFn = func(req providers.ReadDataSourceRequest) (resp providers.ReadDataSourceResponse) {
|
||||
resp.Diagnostics = resp.Diagnostics.Append(fmt.Errorf("data source should not be read"))
|
||||
|
@ -6261,8 +6261,8 @@ data "test_data_source" "e" {
|
|||
|
||||
func TestContext2Plan_skipRefresh(t *testing.T) {
|
||||
p := testProvider("test")
|
||||
p.ApplyFn = testApplyFn
|
||||
p.DiffFn = testDiffFn
|
||||
p.ApplyResourceChangeFn = testApplyFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
m := testModuleInline(t, map[string]string{
|
||||
"main.tf": `
|
||||
|
@ -6307,8 +6307,8 @@ resource "test_instance" "a" {
|
|||
|
||||
func TestContext2Plan_dataInModuleDependsOn(t *testing.T) {
|
||||
p := testProvider("test")
|
||||
p.ApplyFn = testApplyFn
|
||||
p.DiffFn = testDiffFn
|
||||
p.ApplyResourceChangeFn = testApplyFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
readDataSourceB := false
|
||||
p.ReadDataSourceFn = func(req providers.ReadDataSourceRequest) (resp providers.ReadDataSourceResponse) {
|
||||
|
|
|
@ -52,7 +52,7 @@ func TestContext2Refresh(t *testing.T) {
|
|||
p.ReadResourceResponse = providers.ReadResourceResponse{
|
||||
NewState: readState,
|
||||
}
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
s, diags := ctx.Refresh()
|
||||
if diags.HasErrors() {
|
||||
|
@ -282,7 +282,7 @@ func TestContext2Refresh_targeted(t *testing.T) {
|
|||
NewState: req.PriorState,
|
||||
}
|
||||
}
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
_, diags := ctx.Refresh()
|
||||
if diags.HasErrors() {
|
||||
|
@ -361,7 +361,7 @@ func TestContext2Refresh_targetedCount(t *testing.T) {
|
|||
NewState: req.PriorState,
|
||||
}
|
||||
}
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
_, diags := ctx.Refresh()
|
||||
if diags.HasErrors() {
|
||||
|
@ -448,7 +448,7 @@ func TestContext2Refresh_targetedCountIndex(t *testing.T) {
|
|||
NewState: req.PriorState,
|
||||
}
|
||||
}
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
_, diags := ctx.Refresh()
|
||||
if diags.HasErrors() {
|
||||
|
@ -480,7 +480,7 @@ func TestContext2Refresh_moduleComputedVar(t *testing.T) {
|
|||
},
|
||||
},
|
||||
}
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
m := testModule(t, "refresh-module-computed-var")
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
|
@ -517,7 +517,7 @@ func TestContext2Refresh_delete(t *testing.T) {
|
|||
p.ReadResourceResponse = providers.ReadResourceResponse{
|
||||
NewState: cty.NullVal(p.GetSchemaReturn.ResourceTypes["aws_instance"].ImpliedType()),
|
||||
}
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
s, diags := ctx.Refresh()
|
||||
if diags.HasErrors() {
|
||||
|
@ -547,7 +547,7 @@ func TestContext2Refresh_ignoreUncreated(t *testing.T) {
|
|||
"id": cty.StringVal("foo"),
|
||||
}),
|
||||
}
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
_, diags := ctx.Refresh()
|
||||
if diags.HasErrors() {
|
||||
|
@ -561,7 +561,7 @@ func TestContext2Refresh_ignoreUncreated(t *testing.T) {
|
|||
func TestContext2Refresh_hook(t *testing.T) {
|
||||
h := new(MockHook)
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
m := testModule(t, "refresh-basic")
|
||||
|
||||
state := states.NewState()
|
||||
|
@ -623,7 +623,7 @@ func TestContext2Refresh_modules(t *testing.T) {
|
|||
NewState: new,
|
||||
}
|
||||
}
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
s, diags := ctx.Refresh()
|
||||
if diags.HasErrors() {
|
||||
|
@ -640,7 +640,7 @@ func TestContext2Refresh_modules(t *testing.T) {
|
|||
func TestContext2Refresh_moduleInputComputedOutput(t *testing.T) {
|
||||
m := testModule(t, "refresh-module-input-computed-output")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
p.GetSchemaReturn = &ProviderSchema{
|
||||
Provider: &configschema.Block{},
|
||||
ResourceTypes: map[string]*configschema.Block{
|
||||
|
@ -675,7 +675,7 @@ func TestContext2Refresh_moduleInputComputedOutput(t *testing.T) {
|
|||
func TestContext2Refresh_moduleVarModule(t *testing.T) {
|
||||
m := testModule(t, "refresh-module-var-module")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
Providers: map[addrs.Provider]providers.Factory{
|
||||
|
@ -705,7 +705,7 @@ func TestContext2Refresh_noState(t *testing.T) {
|
|||
"id": cty.StringVal("foo"),
|
||||
}),
|
||||
}
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
if _, diags := ctx.Refresh(); diags.HasErrors() {
|
||||
t.Fatalf("refresh errs: %s", diags.Err())
|
||||
|
@ -732,7 +732,7 @@ func TestContext2Refresh_output(t *testing.T) {
|
|||
},
|
||||
},
|
||||
}
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
m := testModule(t, "refresh-output")
|
||||
|
||||
|
@ -768,7 +768,7 @@ func TestContext2Refresh_outputPartial(t *testing.T) {
|
|||
// Refresh creates a partial plan for any instances that don't have
|
||||
// remote objects yet, to get stub values for interpolation. Therefore
|
||||
// we need to make DiffFn available to let that complete.
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
p.GetSchemaReturn = &ProviderSchema{
|
||||
Provider: &configschema.Block{},
|
||||
|
@ -840,7 +840,7 @@ func TestContext2Refresh_stateBasic(t *testing.T) {
|
|||
}
|
||||
|
||||
p.ReadResourceFn = nil
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
p.ReadResourceResponse = providers.ReadResourceResponse{
|
||||
NewState: readStateVal,
|
||||
}
|
||||
|
@ -949,7 +949,7 @@ func TestContext2Refresh_dataState(t *testing.T) {
|
|||
State: readStateVal,
|
||||
}
|
||||
}
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
s, diags := ctx.Refresh()
|
||||
if diags.HasErrors() {
|
||||
|
@ -1015,7 +1015,7 @@ func TestContext2Refresh_dataStateRefData(t *testing.T) {
|
|||
State: cty.ObjectVal(m),
|
||||
}
|
||||
}
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
s, diags := ctx.Refresh()
|
||||
if diags.HasErrors() {
|
||||
|
@ -1053,7 +1053,7 @@ func TestContext2Refresh_tainted(t *testing.T) {
|
|||
NewState: cty.ObjectVal(m),
|
||||
}
|
||||
}
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
s, diags := ctx.Refresh()
|
||||
if diags.HasErrors() {
|
||||
|
@ -1077,8 +1077,8 @@ func TestContext2Refresh_tainted(t *testing.T) {
|
|||
func TestContext2Refresh_unknownProvider(t *testing.T) {
|
||||
m := testModule(t, "refresh-unknown-provider")
|
||||
p := testProvider("aws")
|
||||
p.ApplyFn = testApplyFn
|
||||
p.DiffFn = testDiffFn
|
||||
p.ApplyResourceChangeFn = testApplyFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
state := states.NewState()
|
||||
root := state.EnsureModule(addrs.RootModuleInstance)
|
||||
|
@ -1141,7 +1141,7 @@ func TestContext2Refresh_vars(t *testing.T) {
|
|||
}
|
||||
|
||||
p.ReadResourceFn = nil
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
p.ReadResourceResponse = providers.ReadResourceResponse{
|
||||
NewState: readStateVal,
|
||||
}
|
||||
|
@ -1195,7 +1195,7 @@ func TestContext2Refresh_orphanModule(t *testing.T) {
|
|||
NewState: req.PriorState,
|
||||
}
|
||||
}
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
state := states.NewState()
|
||||
root := state.EnsureModule(addrs.RootModuleInstance)
|
||||
|
@ -1265,7 +1265,7 @@ func TestContext2Validate(t *testing.T) {
|
|||
},
|
||||
},
|
||||
}
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
m := testModule(t, "validate-good")
|
||||
c := testContext2(t, &ContextOpts{
|
||||
|
@ -1284,8 +1284,8 @@ func TestContext2Validate(t *testing.T) {
|
|||
func TestContext2Refresh_updateProviderInState(t *testing.T) {
|
||||
m := testModule(t, "update-resource-provider")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.ApplyFn = testApplyFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
p.ApplyResourceChangeFn = testApplyFn
|
||||
|
||||
state := states.NewState()
|
||||
root := state.EnsureModule(addrs.RootModuleInstance)
|
||||
|
@ -1338,7 +1338,7 @@ func TestContext2Refresh_schemaUpgradeFlatmap(t *testing.T) {
|
|||
"name": cty.StringVal("foo"),
|
||||
}),
|
||||
}
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
s := states.BuildState(func(s *states.SyncState) {
|
||||
s.SetResourceInstanceCurrent(
|
||||
|
@ -1425,7 +1425,7 @@ func TestContext2Refresh_schemaUpgradeJSON(t *testing.T) {
|
|||
"name": cty.StringVal("foo"),
|
||||
}),
|
||||
}
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
s := states.BuildState(func(s *states.SyncState) {
|
||||
s.SetResourceInstanceCurrent(
|
||||
|
@ -1503,7 +1503,7 @@ data "aws_data_source" "foo" {
|
|||
resp.State = req.Config
|
||||
return
|
||||
}
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
|
@ -1544,7 +1544,7 @@ func TestContext2Refresh_dataResourceDependsOn(t *testing.T) {
|
|||
},
|
||||
},
|
||||
}
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
p.ReadDataSourceResponse = providers.ReadDataSourceResponse{
|
||||
State: cty.ObjectVal(map[string]cty.Value{
|
||||
"compute": cty.StringVal("value"),
|
||||
|
@ -1653,8 +1653,8 @@ resource "aws_instance" "foo" {
|
|||
})
|
||||
|
||||
p := testProvider("aws")
|
||||
p.ApplyFn = testApplyFn
|
||||
p.DiffFn = testDiffFn
|
||||
p.ApplyResourceChangeFn = testApplyFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
|
@ -1722,8 +1722,8 @@ resource "aws_instance" "bar" {
|
|||
})
|
||||
|
||||
p := testProvider("aws")
|
||||
p.ApplyFn = testApplyFn
|
||||
p.DiffFn = testDiffFn
|
||||
p.ApplyResourceChangeFn = testApplyFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
|
|
|
@ -928,8 +928,8 @@ func TestContext2Validate_targetedDestroy(t *testing.T) {
|
|||
m := testModule(t, "validate-targeted")
|
||||
p := testProvider("aws")
|
||||
pr := simpleMockProvisioner()
|
||||
p.ApplyFn = testApplyFn
|
||||
p.DiffFn = testDiffFn
|
||||
p.ApplyResourceChangeFn = testApplyFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
p.GetSchemaReturn = &ProviderSchema{
|
||||
ResourceTypes: map[string]*configschema.Block{
|
||||
"aws_instance": {
|
||||
|
@ -1017,8 +1017,8 @@ func TestContext2Validate_interpolateVar(t *testing.T) {
|
|||
|
||||
m := testModule(t, "input-interpolate-var")
|
||||
p := testProvider("null")
|
||||
p.ApplyFn = testApplyFn
|
||||
p.DiffFn = testDiffFn
|
||||
p.ApplyResourceChangeFn = testApplyFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
p.GetSchemaReturn = &ProviderSchema{
|
||||
ResourceTypes: map[string]*configschema.Block{
|
||||
"template_file": {
|
||||
|
@ -1050,8 +1050,8 @@ func TestContext2Validate_interpolateComputedModuleVarDef(t *testing.T) {
|
|||
|
||||
m := testModule(t, "validate-computed-module-var-ref")
|
||||
p := testProvider("aws")
|
||||
p.ApplyFn = testApplyFn
|
||||
p.DiffFn = testDiffFn
|
||||
p.ApplyResourceChangeFn = testApplyFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
p.GetSchemaReturn = &ProviderSchema{
|
||||
ResourceTypes: map[string]*configschema.Block{
|
||||
"aws_instance": {
|
||||
|
@ -1082,8 +1082,8 @@ func TestContext2Validate_interpolateMap(t *testing.T) {
|
|||
|
||||
m := testModule(t, "issue-9549")
|
||||
p := testProvider("template")
|
||||
p.ApplyFn = testApplyFn
|
||||
p.DiffFn = testDiffFn
|
||||
p.ApplyResourceChangeFn = testApplyFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
|
@ -1482,7 +1482,7 @@ resource "aws_instance" "foo" {
|
|||
})
|
||||
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
Providers: map[addrs.Provider]providers.Factory{
|
||||
|
@ -1511,7 +1511,7 @@ resource "aws_instance" "foo" {
|
|||
})
|
||||
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
Providers: map[addrs.Provider]providers.Factory{
|
||||
|
@ -1543,7 +1543,7 @@ resource "aws_instance" "foo" {
|
|||
})
|
||||
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
Providers: map[addrs.Provider]providers.Factory{
|
||||
|
@ -1626,7 +1626,7 @@ output "out" {
|
|||
})
|
||||
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
p.PlanResourceChangeFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Config: m,
|
||||
Providers: map[addrs.Provider]providers.Factory{
|
||||
|
|
|
@ -86,9 +86,6 @@ type MockProvider struct {
|
|||
|
||||
CloseCalled bool
|
||||
CloseError error
|
||||
|
||||
DiffFn func(providers.PlanResourceChangeRequest) providers.PlanResourceChangeResponse
|
||||
ApplyFn func(providers.ApplyResourceChangeRequest) providers.ApplyResourceChangeResponse
|
||||
}
|
||||
|
||||
func (p *MockProvider) GetSchema() providers.GetSchemaResponse {
|
||||
|
@ -263,9 +260,6 @@ func (p *MockProvider) PlanResourceChange(r providers.PlanResourceChangeRequest)
|
|||
p.PlanResourceChangeCalled = true
|
||||
p.PlanResourceChangeRequest = r
|
||||
|
||||
if p.DiffFn != nil {
|
||||
return p.DiffFn(r)
|
||||
}
|
||||
if p.PlanResourceChangeFn != nil {
|
||||
return p.PlanResourceChangeFn(r)
|
||||
}
|
||||
|
@ -279,9 +273,6 @@ func (p *MockProvider) ApplyResourceChange(r providers.ApplyResourceChangeReques
|
|||
p.ApplyResourceChangeRequest = r
|
||||
p.Unlock()
|
||||
|
||||
if p.ApplyFn != nil {
|
||||
return p.ApplyFn(r)
|
||||
}
|
||||
if p.ApplyResourceChangeFn != nil {
|
||||
return p.ApplyResourceChangeFn(r)
|
||||
}
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
package terraform
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"github.com/zclconf/go-cty/cty"
|
||||
"github.com/zclconf/go-cty/cty/convert"
|
||||
|
||||
"github.com/hashicorp/terraform/provisioners"
|
||||
)
|
||||
|
||||
|
@ -39,12 +35,6 @@ type MockProvisioner struct {
|
|||
CloseCalled bool
|
||||
CloseResponse error
|
||||
CloseFn func() error
|
||||
|
||||
// Legacy callbacks: if these are set, we will shim incoming calls for
|
||||
// new-style methods to these old-fashioned terraform.ResourceProvider
|
||||
// mock callbacks, for the benefit of older tests that were written against
|
||||
// the old mock API.
|
||||
ApplyFn func(rs *InstanceState, c *ResourceConfig) error
|
||||
}
|
||||
|
||||
func (p *MockProvisioner) GetSchema() provisioners.GetSchemaResponse {
|
||||
|
@ -79,45 +69,6 @@ func (p *MockProvisioner) ProvisionResource(r provisioners.ProvisionResourceRequ
|
|||
|
||||
p.ProvisionResourceCalled = true
|
||||
p.ProvisionResourceRequest = r
|
||||
if p.ApplyFn != nil {
|
||||
if !r.Config.IsKnown() {
|
||||
panic(fmt.Sprintf("cannot provision with unknown value: %#v", r.Config))
|
||||
}
|
||||
|
||||
schema := p.getSchema()
|
||||
rc := NewResourceConfigShimmed(r.Config, schema.Provisioner)
|
||||
connVal := r.Connection
|
||||
connMap := map[string]string{}
|
||||
|
||||
if !connVal.IsNull() && connVal.IsKnown() {
|
||||
for it := connVal.ElementIterator(); it.Next(); {
|
||||
ak, av := it.Element()
|
||||
name := ak.AsString()
|
||||
|
||||
if !av.IsKnown() || av.IsNull() {
|
||||
continue
|
||||
}
|
||||
|
||||
av, _ = convert.Convert(av, cty.String)
|
||||
connMap[name] = av.AsString()
|
||||
}
|
||||
}
|
||||
|
||||
// We no longer pass the full instance state to a provisioner, so we'll
|
||||
// construct a partial one that should be good enough for what existing
|
||||
// test mocks need.
|
||||
is := &InstanceState{
|
||||
Ephemeral: EphemeralState{
|
||||
ConnInfo: connMap,
|
||||
},
|
||||
}
|
||||
var resp provisioners.ProvisionResourceResponse
|
||||
err := p.ApplyFn(is, rc)
|
||||
if err != nil {
|
||||
resp.Diagnostics = resp.Diagnostics.Append(err)
|
||||
}
|
||||
return resp
|
||||
}
|
||||
if p.ProvisionResourceFn != nil {
|
||||
fn := p.ProvisionResourceFn
|
||||
return fn(r)
|
||||
|
|
Loading…
Reference in New Issue