ensure that provisioners are not used after Close
This commit is contained in:
parent
fe7635f438
commit
63a9ab4944
|
@ -9801,14 +9801,17 @@ func TestContext2Apply_plannedConnectionRefs(t *testing.T) {
|
|||
return resp
|
||||
}
|
||||
|
||||
pr := testProvisioner()
|
||||
pr.ProvisionResourceFn = func(req provisioners.ProvisionResourceRequest) (resp provisioners.ProvisionResourceResponse) {
|
||||
host := req.Connection.GetAttr("host")
|
||||
if host.IsNull() || !host.IsKnown() {
|
||||
resp.Diagnostics = resp.Diagnostics.Append(fmt.Errorf("invalid host value: %#v", host))
|
||||
}
|
||||
provisionerFactory := func() (provisioners.Interface, error) {
|
||||
pr := testProvisioner()
|
||||
pr.ProvisionResourceFn = func(req provisioners.ProvisionResourceRequest) (resp provisioners.ProvisionResourceResponse) {
|
||||
host := req.Connection.GetAttr("host")
|
||||
if host.IsNull() || !host.IsKnown() {
|
||||
resp.Diagnostics = resp.Diagnostics.Append(fmt.Errorf("invalid host value: %#v", host))
|
||||
}
|
||||
|
||||
return resp
|
||||
return resp
|
||||
}
|
||||
return pr, nil
|
||||
}
|
||||
|
||||
Providers := map[addrs.Provider]providers.Factory{
|
||||
|
@ -9816,7 +9819,7 @@ func TestContext2Apply_plannedConnectionRefs(t *testing.T) {
|
|||
}
|
||||
|
||||
provisioners := map[string]provisioners.Factory{
|
||||
"shell": testProvisionerFuncFixed(pr),
|
||||
"shell": provisionerFactory,
|
||||
}
|
||||
|
||||
hook := &testHook{}
|
||||
|
@ -12163,6 +12166,7 @@ output "out" {
|
|||
func TestContext2Apply_provisionerSensitive(t *testing.T) {
|
||||
m := testModule(t, "apply-provisioner-sensitive")
|
||||
p := testProvider("aws")
|
||||
|
||||
pr := testProvisioner()
|
||||
pr.ProvisionResourceFn = func(req provisioners.ProvisionResourceRequest) (resp provisioners.ProvisionResourceResponse) {
|
||||
if req.Config.ContainsMarked() {
|
||||
|
@ -12201,6 +12205,9 @@ func TestContext2Apply_provisionerSensitive(t *testing.T) {
|
|||
t.Fatal("plan failed")
|
||||
}
|
||||
|
||||
// "restart" provisioner
|
||||
pr.CloseCalled = false
|
||||
|
||||
state, diags := ctx.Apply()
|
||||
if diags.HasErrors() {
|
||||
logDiagnostics(t, diags)
|
||||
|
|
|
@ -170,8 +170,10 @@ func testProviderFuncFixed(rp providers.Interface) providers.Factory {
|
|||
}
|
||||
}
|
||||
|
||||
func testProvisionerFuncFixed(rp provisioners.Interface) provisioners.Factory {
|
||||
func testProvisionerFuncFixed(rp *MockProvisioner) provisioners.Factory {
|
||||
return func() (provisioners.Interface, error) {
|
||||
// make sure this provisioner has has not been closed
|
||||
rp.CloseCalled = false
|
||||
return rp, nil
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue