export MustShimLegacyState for resource tests

We also need to convert legacy states for helper resource tests.
This commit is contained in:
James Bardin 2018-10-15 21:07:01 -04:00 committed by Martin Atkins
parent c990c9f36d
commit b3fed27dbf
13 changed files with 173 additions and 171 deletions

View File

@ -1,6 +1,7 @@
package terraform
import (
"bytes"
"context"
"fmt"
"log"
@ -18,6 +19,7 @@ import (
"github.com/hashicorp/terraform/providers"
"github.com/hashicorp/terraform/provisioners"
"github.com/hashicorp/terraform/states"
"github.com/hashicorp/terraform/states/statefile"
"github.com/hashicorp/terraform/tfdiags"
)
@ -897,3 +899,37 @@ func parseVariableAsHCL(name string, input string, targetType config.VariableTyp
panic(fmt.Errorf("unknown type %s", targetType.Printable()))
}
}
// shimLegacyState is a helper that takes the legacy state type and
// converts it to the new state type.
//
// This is implemented as a state file upgrade, so it will not preserve
// parts of the state structure that are not included in a serialized state,
// such as the resolved results of any local values, outputs in non-root
// modules, etc.
func shimLegacyState(legacy *State) (*states.State, error) {
if legacy == nil {
return nil, nil
}
var buf bytes.Buffer
err := WriteState(legacy, &buf)
if err != nil {
return nil, err
}
f, err := statefile.Read(&buf)
if err != nil {
return nil, err
}
return f.State, err
}
// MustShimLegacyState is a wrapper around ShimLegacyState that panics if
// the conversion does not succeed. This is primarily intended for tests where
// the given legacy state is an object constructed within the test.
func MustShimLegacyState(legacy *State) *states.State {
ret, err := shimLegacyState(legacy)
if err != nil {
panic(err)
}
return ret
}

View File

@ -290,7 +290,7 @@ func TestContext2Apply_resourceDependsOnModuleStateOnly(t *testing.T) {
p := testProvider("aws")
p.DiffFn = testDiffFn
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -811,7 +811,7 @@ func TestContext2Apply_createBeforeDestroy(t *testing.T) {
p := testProvider("aws")
p.ApplyFn = testApplyFn
p.DiffFn = testDiffFn
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -868,7 +868,7 @@ func TestContext2Apply_createBeforeDestroyUpdate(t *testing.T) {
p := testProvider("aws")
p.ApplyFn = testApplyFn
p.DiffFn = testDiffFn
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -926,7 +926,7 @@ func TestContext2Apply_createBeforeDestroy_dependsNonCBD(t *testing.T) {
p := testProvider("aws")
p.ApplyFn = testApplyFn
p.DiffFn = testDiffFn
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -999,7 +999,7 @@ func TestContext2Apply_createBeforeDestroy_hook(t *testing.T) {
p := testProvider("aws")
p.ApplyFn = testApplyFn
p.DiffFn = testDiffFn
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -1072,7 +1072,7 @@ func TestContext2Apply_createBeforeDestroy_deposedCount(t *testing.T) {
p.ApplyFn = testApplyFn
p.DiffFn = testDiffFn
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -1151,7 +1151,7 @@ func TestContext2Apply_createBeforeDestroy_deposedOnly(t *testing.T) {
p.ApplyFn = testApplyFn
p.DiffFn = testDiffFn
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -1207,7 +1207,7 @@ func TestContext2Apply_destroyComputed(t *testing.T) {
p := testProvider("aws")
p.ApplyFn = testApplyFn
p.DiffFn = testDiffFn
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -1264,7 +1264,7 @@ func testContext2Apply_destroyDependsOn(t *testing.T) {
p := testProvider("aws")
p.ApplyFn = testApplyFn
p.DiffFn = testDiffFn
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -1341,7 +1341,7 @@ func testContext2Apply_destroyDependsOnStateOnly(t *testing.T) {
p := testProvider("aws")
p.ApplyFn = testApplyFn
p.DiffFn = testDiffFn
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -1421,7 +1421,7 @@ func testContext2Apply_destroyDependsOnStateOnlyModule(t *testing.T) {
p := testProvider("aws")
p.ApplyFn = testApplyFn
p.DiffFn = testDiffFn
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: []string{"root", "child"},
@ -1528,7 +1528,7 @@ func TestContext2Apply_destroyData(t *testing.T) {
p := testProvider("null")
p.ApplyFn = testApplyFn
p.DiffFn = testDiffFn
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -1598,7 +1598,7 @@ func TestContext2Apply_destroySkipsCBD(t *testing.T) {
p := testProvider("aws")
p.ApplyFn = testApplyFn
p.DiffFn = testDiffFn
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -1646,7 +1646,7 @@ func TestContext2Apply_destroyModuleVarProviderConfig(t *testing.T) {
p := testProvider("aws")
p.ApplyFn = testApplyFn
p.DiffFn = testDiffFn
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: []string{"root", "child"},
@ -1735,7 +1735,7 @@ func TestContext2Apply_destroyCrossProviders(t *testing.T) {
}
func getContextForApply_destroyCrossProviders(t *testing.T, m *configs.Config, providerFactories map[string]providers.Factory) *Context {
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -2150,7 +2150,7 @@ func TestContext2Apply_countDecrease(t *testing.T) {
p := testProvider("aws")
p.DiffFn = testDiffFn
p.ApplyFn = testApplyFn
s := mustShimLegacyState(&State{
s := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -2219,7 +2219,7 @@ func TestContext2Apply_countDecreaseToOneX(t *testing.T) {
p := testProvider("aws")
p.ApplyFn = testApplyFn
p.DiffFn = testDiffFn
s := mustShimLegacyState(&State{
s := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -2286,7 +2286,7 @@ func TestContext2Apply_countDecreaseToOneCorrupted(t *testing.T) {
p := testProvider("aws")
p.ApplyFn = testApplyFn
p.DiffFn = testDiffFn
s := mustShimLegacyState(&State{
s := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -2351,7 +2351,7 @@ func TestContext2Apply_countTainted(t *testing.T) {
p := testProvider("aws")
p.DiffFn = testDiffFn
p.ApplyFn = testApplyFn
s := mustShimLegacyState(&State{
s := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -2609,7 +2609,7 @@ func TestContext2Apply_moduleDestroyOrder(t *testing.T) {
},
}
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -2818,7 +2818,7 @@ func TestContext2Apply_moduleOrphanInheritAlias(t *testing.T) {
}
// Create a state with an orphan module
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: []string{"root", "child"},
@ -2876,7 +2876,7 @@ func TestContext2Apply_moduleOrphanProvider(t *testing.T) {
}
// Create a state with an orphan module
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: []string{"root", "child"},
@ -2927,7 +2927,7 @@ func TestContext2Apply_moduleOrphanGrandchildProvider(t *testing.T) {
}
// Create a state with an orphan module that is nested (grandchild)
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: []string{"root", "parent", "child"},
@ -3129,7 +3129,7 @@ func TestContext2Apply_moduleProviderCloseNested(t *testing.T) {
"aws": testProviderFuncFixed(p),
},
),
State: mustShimLegacyState(&State{
State: MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: []string{"root", "child", "subchild"},
@ -3167,7 +3167,7 @@ func TestContext2Apply_moduleVarRefExisting(t *testing.T) {
p.ApplyFn = testApplyFn
p.DiffFn = testDiffFn
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -4263,7 +4263,7 @@ func TestContext2Apply_outputOrphan(t *testing.T) {
p.ApplyFn = testApplyFn
p.DiffFn = testDiffFn
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -4315,7 +4315,7 @@ func TestContext2Apply_outputOrphanModule(t *testing.T) {
p.ApplyFn = testApplyFn
p.DiffFn = testDiffFn
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: []string{"root", "child"},
@ -4705,7 +4705,7 @@ func TestContext2Apply_provisionerFail_createBeforeDestroy(t *testing.T) {
return fmt.Errorf("EXPLOSION")
}
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -4755,7 +4755,7 @@ func TestContext2Apply_provisionerFail_createBeforeDestroy(t *testing.T) {
func TestContext2Apply_error_createBeforeDestroy(t *testing.T) {
m := testModule(t, "apply-error-create-before")
p := testProvider("aws")
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -4806,7 +4806,7 @@ func TestContext2Apply_error_createBeforeDestroy(t *testing.T) {
func TestContext2Apply_errorDestroy_createBeforeDestroy(t *testing.T) {
m := testModule(t, "apply-error-create-before")
p := testProvider("aws")
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -4878,7 +4878,7 @@ func TestContext2Apply_multiDepose_createBeforeDestroy(t *testing.T) {
},
}
ps := map[string]providers.Factory{"aws": testProviderFuncFixed(p)}
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -5146,7 +5146,7 @@ func TestContext2Apply_provisionerDestroy(t *testing.T) {
return nil
}
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -5204,7 +5204,7 @@ func TestContext2Apply_provisionerDestroyFail(t *testing.T) {
return fmt.Errorf("provisioner error")
}
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -5278,7 +5278,7 @@ func TestContext2Apply_provisionerDestroyFailContinue(t *testing.T) {
return fmt.Errorf("provisioner error")
}
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -5354,7 +5354,7 @@ func TestContext2Apply_provisionerDestroyFailContinueFail(t *testing.T) {
return fmt.Errorf("provisioner error")
}
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -5434,7 +5434,7 @@ func TestContext2Apply_provisionerDestroyTainted(t *testing.T) {
return nil
}
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -5506,7 +5506,7 @@ func TestContext2Apply_provisionerDestroyModule(t *testing.T) {
return nil
}
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: []string{"root", "child"},
@ -5568,7 +5568,7 @@ func TestContext2Apply_provisionerDestroyRef(t *testing.T) {
return nil
}
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -5638,7 +5638,7 @@ func TestContext2Apply_provisionerDestroyRefInvalid(t *testing.T) {
return nil
}
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -6077,7 +6077,7 @@ func TestContext2Apply_Provisioner_Diff(t *testing.T) {
func TestContext2Apply_outputDiffVars(t *testing.T) {
m := testModule(t, "apply-good")
p := testProvider("aws")
s := mustShimLegacyState(&State{
s := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -6333,7 +6333,7 @@ func TestContext2Apply_destroyNestedModule(t *testing.T) {
p.ApplyFn = testApplyFn
p.DiffFn = testDiffFn
s := mustShimLegacyState(&State{
s := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: []string{"root", "child", "subchild"},
@ -6383,7 +6383,7 @@ func TestContext2Apply_destroyDeeplyNestedModule(t *testing.T) {
p.ApplyFn = testApplyFn
p.DiffFn = testDiffFn
s := mustShimLegacyState(&State{
s := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: []string{"root", "child", "subchild", "subsubchild"},
@ -6825,7 +6825,7 @@ func TestContext2Apply_destroyOutputs(t *testing.T) {
func TestContext2Apply_destroyOrphan(t *testing.T) {
m := testModule(t, "apply-error")
p := testProvider("aws")
s := mustShimLegacyState(&State{
s := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -6897,7 +6897,7 @@ func TestContext2Apply_destroyTaintedProvisioner(t *testing.T) {
return nil
}
s := mustShimLegacyState(&State{
s := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -7012,7 +7012,7 @@ func TestContext2Apply_errorPartial(t *testing.T) {
m := testModule(t, "apply-error")
p := testProvider("aws")
s := mustShimLegacyState(&State{
s := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -7123,7 +7123,7 @@ func TestContext2Apply_hookOrphan(t *testing.T) {
p.ApplyFn = testApplyFn
p.DiffFn = testDiffFn
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -7417,7 +7417,7 @@ func TestContext2Apply_taintX(t *testing.T) {
return testApplyFn(info, s, d)
}
p.DiffFn = testDiffFn
s := mustShimLegacyState(&State{
s := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -7474,7 +7474,7 @@ func TestContext2Apply_taintDep(t *testing.T) {
p := testProvider("aws")
p.ApplyFn = testApplyFn
p.DiffFn = testDiffFn
s := mustShimLegacyState(&State{
s := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -7538,7 +7538,7 @@ func TestContext2Apply_taintDepRequiresNew(t *testing.T) {
p := testProvider("aws")
p.ApplyFn = testApplyFn
p.DiffFn = testDiffFn
s := mustShimLegacyState(&State{
s := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -7727,7 +7727,7 @@ func TestContext2Apply_targetedDestroy(t *testing.T) {
"aws": testProviderFuncFixed(p),
},
),
State: mustShimLegacyState(&State{
State: MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -7806,7 +7806,7 @@ func TestContext2Apply_destroyProvisionerWithLocals(t *testing.T) {
Provisioners: map[string]ProvisionerFactory{
"shell": testProvisionerFuncFixed(pr),
},
State: mustShimLegacyState(&State{
State: MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: []string{"root"},
@ -7903,7 +7903,7 @@ func TestContext2Apply_destroyProvisionerWithMultipleLocals(t *testing.T) {
Provisioners: map[string]ProvisionerFactory{
"shell": testProvisionerFuncFixed(pr),
},
State: mustShimLegacyState(&State{
State: MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: []string{"root"},
@ -7954,7 +7954,7 @@ func TestContext2Apply_destroyProvisionerWithOutput(t *testing.T) {
Provisioners: map[string]ProvisionerFactory{
"shell": testProvisionerFuncFixed(pr),
},
State: mustShimLegacyState(&State{
State: MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: []string{"root"},
@ -8027,7 +8027,7 @@ func TestContext2Apply_targetedDestroyCountDeps(t *testing.T) {
"aws": testProviderFuncFixed(p),
},
),
State: mustShimLegacyState(&State{
State: MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -8071,7 +8071,7 @@ func TestContext2Apply_targetedDestroyModule(t *testing.T) {
"aws": testProviderFuncFixed(p),
},
),
State: mustShimLegacyState(&State{
State: MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -8133,7 +8133,7 @@ func TestContext2Apply_targetedDestroyCountIndex(t *testing.T) {
"aws": testProviderFuncFixed(p),
},
),
State: mustShimLegacyState(&State{
State: MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -8303,7 +8303,7 @@ func TestContext2Apply_targetedModuleUnrelatedOutputs(t *testing.T) {
Targets: []addrs.Targetable{
addrs.RootModuleInstance.Child("child2", addrs.NoKey),
},
State: mustShimLegacyState(&State{
State: MustShimLegacyState(&State{
Modules: []*ModuleState{
{
Path: []string{"root"},
@ -8558,7 +8558,7 @@ func TestContext2Apply_createBefore_depends(t *testing.T) {
p := testProvider("aws")
p.ApplyFn = testApplyFn
p.DiffFn = testDiffFn
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -8673,7 +8673,7 @@ func TestContext2Apply_singleDestroy(t *testing.T) {
return testApplyFn(info, s, d)
}
p.DiffFn = testDiffFn
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -8899,7 +8899,7 @@ func TestContext2Apply_targetedWithTaintedInState(t *testing.T) {
addrs.ManagedResourceMode, "aws_instance", "iambeingadded",
),
},
State: mustShimLegacyState(&State{
State: MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -9035,7 +9035,7 @@ func TestContext2Apply_ignoreChangesWithDep(t *testing.T) {
return nil, nil
}
}
s := mustShimLegacyState(&State{
s := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -9450,7 +9450,7 @@ func TestContext2Apply_destroyWithLocals(t *testing.T) {
d, err := testDiffFn(info, s, c)
return d, err
}
s := mustShimLegacyState(&State{
s := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -9571,7 +9571,7 @@ func TestContext2Apply_destroyWithProviders(t *testing.T) {
p.ApplyFn = testApplyFn
p.DiffFn = testDiffFn
s := mustShimLegacyState(&State{
s := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -9646,7 +9646,7 @@ func TestContext2Apply_providersFromState(t *testing.T) {
}{
{
name: "add implicit provider",
state: mustShimLegacyState(&State{
state: MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: []string{"root"},
@ -9669,7 +9669,7 @@ func TestContext2Apply_providersFromState(t *testing.T) {
// an aliased provider must be in the config to remove a resource
{
name: "add aliased provider",
state: mustShimLegacyState(&State{
state: MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: []string{"root"},
@ -9692,7 +9692,7 @@ func TestContext2Apply_providersFromState(t *testing.T) {
// allowed even without an alias
{
name: "add unaliased module provider",
state: mustShimLegacyState(&State{
state: MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: []string{"root", "child"},
@ -9759,7 +9759,7 @@ func TestContext2Apply_plannedInterpolatedCount(t *testing.T) {
},
)
s := mustShimLegacyState(&State{
s := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -9821,7 +9821,7 @@ func TestContext2Apply_plannedDestroyInterpolatedCount(t *testing.T) {
},
)
s := mustShimLegacyState(&State{
s := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -9898,7 +9898,7 @@ func TestContext2Apply_scaleInMultivarRef(t *testing.T) {
},
)
s := mustShimLegacyState(&State{
s := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,

View File

@ -86,7 +86,7 @@ func TestContext2Plan_createBefore_deposed(t *testing.T) {
p := testProvider("aws")
p.DiffFn = testDiffFn
s := mustShimLegacyState(&State{
s := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: []string{"root"},
@ -800,7 +800,7 @@ func TestContext2Plan_moduleOrphans(t *testing.T) {
m := testModule(t, "plan-modules-remove")
p := testProvider("aws")
p.DiffFn = testDiffFn
s := mustShimLegacyState(&State{
s := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: []string{"root", "child"},
@ -880,7 +880,7 @@ func TestContext2Plan_moduleOrphansWithProvisioner(t *testing.T) {
p := testProvider("aws")
pr := testProvisioner()
p.DiffFn = testDiffFn
s := mustShimLegacyState(&State{
s := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: []string{"root"},
@ -1422,7 +1422,7 @@ func TestContext2Plan_preventDestroy_bad(t *testing.T) {
"aws": testProviderFuncFixed(p),
},
),
State: mustShimLegacyState(&State{
State: MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -1461,7 +1461,7 @@ func TestContext2Plan_preventDestroy_good(t *testing.T) {
"aws": testProviderFuncFixed(p),
},
),
State: mustShimLegacyState(&State{
State: MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -1499,7 +1499,7 @@ func TestContext2Plan_preventDestroy_countBad(t *testing.T) {
"aws": testProviderFuncFixed(p),
},
),
State: mustShimLegacyState(&State{
State: MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -1554,7 +1554,7 @@ func TestContext2Plan_preventDestroy_countGood(t *testing.T) {
"aws": testProviderFuncFixed(p),
},
),
State: mustShimLegacyState(&State{
State: MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -1608,7 +1608,7 @@ func TestContext2Plan_preventDestroy_countGoodNoChange(t *testing.T) {
"aws": testProviderFuncFixed(p),
},
),
State: mustShimLegacyState(&State{
State: MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -1650,7 +1650,7 @@ func TestContext2Plan_preventDestroy_destroyPlan(t *testing.T) {
"aws": testProviderFuncFixed(p),
},
),
State: mustShimLegacyState(&State{
State: MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -2007,7 +2007,7 @@ func TestContext2Plan_dataResourceBecomesComputed(t *testing.T) {
"aws": testProviderFuncFixed(p),
},
),
State: mustShimLegacyState(&State{
State: MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -2653,7 +2653,7 @@ func TestContext2Plan_countDecreaseToOne(t *testing.T) {
m := testModule(t, "plan-count-dec")
p := testProvider("aws")
p.DiffFn = testDiffFn
s := mustShimLegacyState(&State{
s := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -2760,7 +2760,7 @@ func TestContext2Plan_countIncreaseFromNotSet(t *testing.T) {
m := testModule(t, "plan-count-inc")
p := testProvider("aws")
p.DiffFn = testDiffFn
s := mustShimLegacyState(&State{
s := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -2849,7 +2849,7 @@ func TestContext2Plan_countIncreaseFromOne(t *testing.T) {
m := testModule(t, "plan-count-inc")
p := testProvider("aws")
p.DiffFn = testDiffFn
s := mustShimLegacyState(&State{
s := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -2943,7 +2943,7 @@ func TestContext2Plan_countIncreaseFromOneCorrupted(t *testing.T) {
m := testModule(t, "plan-count-inc")
p := testProvider("aws")
p.DiffFn = testDiffFn
s := mustShimLegacyState(&State{
s := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -3065,7 +3065,7 @@ func TestContext2Plan_countIncreaseWithSplatReference(t *testing.T) {
}
p.DiffFn = testDiffFn
s := mustShimLegacyState(&State{
s := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -3167,7 +3167,7 @@ func TestContext2Plan_destroy(t *testing.T) {
m := testModule(t, "plan-destroy")
p := testProvider("aws")
p.DiffFn = testDiffFn
s := mustShimLegacyState(&State{
s := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -3233,7 +3233,7 @@ func TestContext2Plan_moduleDestroy(t *testing.T) {
m := testModule(t, "plan-module-destroy")
p := testProvider("aws")
p.DiffFn = testDiffFn
s := mustShimLegacyState(&State{
s := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -3304,7 +3304,7 @@ func TestContext2Plan_moduleDestroyCycle(t *testing.T) {
m := testModule(t, "plan-module-destroy-gh-1835")
p := testProvider("aws")
p.DiffFn = testDiffFn
s := mustShimLegacyState(&State{
s := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: []string{"root", "a_module"},
@ -3375,7 +3375,7 @@ func TestContext2Plan_moduleDestroyMultivar(t *testing.T) {
m := testModule(t, "plan-module-destroy-multivar")
p := testProvider("aws")
p.DiffFn = testDiffFn
s := mustShimLegacyState(&State{
s := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -3508,7 +3508,7 @@ func TestContext2Plan_pathVar(t *testing.T) {
func TestContext2Plan_diffVar(t *testing.T) {
m := testModule(t, "plan-diffvar")
p := testProvider("aws")
s := mustShimLegacyState(&State{
s := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -3658,7 +3658,7 @@ func TestContext2Plan_orphan(t *testing.T) {
m := testModule(t, "plan-orphan")
p := testProvider("aws")
p.DiffFn = testDiffFn
s := mustShimLegacyState(&State{
s := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -3746,7 +3746,7 @@ func TestContext2Plan_state(t *testing.T) {
m := testModule(t, "plan-good")
p := testProvider("aws")
p.DiffFn = testDiffFn
s := mustShimLegacyState(&State{
s := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -3826,7 +3826,7 @@ func TestContext2Plan_taint(t *testing.T) {
m := testModule(t, "plan-taint")
p := testProvider("aws")
p.DiffFn = testDiffFn
s := mustShimLegacyState(&State{
s := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -3914,7 +3914,7 @@ func TestContext2Plan_taintIgnoreChanges(t *testing.T) {
p.ApplyFn = testApplyFn
p.DiffFn = testDiffFn
s := mustShimLegacyState(&State{
s := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -3988,7 +3988,7 @@ func TestContext2Plan_taintDestroyInterpolatedCountRace(t *testing.T) {
m := testModule(t, "plan-taint-interpolated-count")
p := testProvider("aws")
p.DiffFn = testDiffFn
s := mustShimLegacyState(&State{
s := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -4234,7 +4234,7 @@ func TestContext2Plan_targetedOrphan(t *testing.T) {
"aws": testProviderFuncFixed(p),
},
),
State: mustShimLegacyState(&State{
State: MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -4304,7 +4304,7 @@ func TestContext2Plan_targetedModuleOrphan(t *testing.T) {
"aws": testProviderFuncFixed(p),
},
),
State: mustShimLegacyState(&State{
State: MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: []string{"root", "child"},
@ -4468,7 +4468,7 @@ func TestContext2Plan_targetedOverTen(t *testing.T) {
"aws": testProviderFuncFixed(p),
},
),
State: mustShimLegacyState(&State{
State: MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -4562,7 +4562,7 @@ func TestContext2Plan_ignoreChanges(t *testing.T) {
p.DiffFn = testDiffFn
s := mustShimLegacyState(&State{
s := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -4631,7 +4631,7 @@ func TestContext2Plan_ignoreChangesWildcard(t *testing.T) {
p := testProvider("aws")
p.DiffFn = testDiffFn
s := mustShimLegacyState(&State{
s := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -5036,7 +5036,7 @@ func TestContext2Plan_ignoreChangesWithFlatmaps(t *testing.T) {
},
},
}
s := mustShimLegacyState(&State{
s := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -5124,7 +5124,7 @@ func TestContext2Plan_resourceNestedCount(t *testing.T) {
NewState: req.PriorState,
}
}
s := mustShimLegacyState(&State{
s := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,

View File

@ -21,7 +21,7 @@ func TestContext2Refresh(t *testing.T) {
p := testProvider("aws")
m := testModule(t, "refresh-basic")
startingState := mustShimLegacyState(&State{
startingState := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -189,7 +189,7 @@ func TestContext2Refresh_targeted(t *testing.T) {
"aws": testProviderFuncFixed(p),
},
),
State: mustShimLegacyState(&State{
State: MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -272,7 +272,7 @@ func TestContext2Refresh_targetedCount(t *testing.T) {
"aws": testProviderFuncFixed(p),
},
),
State: mustShimLegacyState(&State{
State: MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -365,7 +365,7 @@ func TestContext2Refresh_targetedCountIndex(t *testing.T) {
"aws": testProviderFuncFixed(p),
},
),
State: mustShimLegacyState(&State{
State: MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -453,7 +453,7 @@ func TestContext2Refresh_delete(t *testing.T) {
"aws": testProviderFuncFixed(p),
},
),
State: mustShimLegacyState(&State{
State: MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -527,7 +527,7 @@ func TestContext2Refresh_hook(t *testing.T) {
"aws": testProviderFuncFixed(p),
},
),
State: mustShimLegacyState(&State{
State: MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -558,7 +558,7 @@ func TestContext2Refresh_hook(t *testing.T) {
func TestContext2Refresh_modules(t *testing.T) {
p := testProvider("aws")
m := testModule(t, "refresh-modules")
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -733,7 +733,7 @@ func TestContext2Refresh_output(t *testing.T) {
"aws": testProviderFuncFixed(p),
},
),
State: mustShimLegacyState(&State{
State: MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -809,7 +809,7 @@ func TestContext2Refresh_outputPartial(t *testing.T) {
"aws": testProviderFuncFixed(p),
},
),
State: mustShimLegacyState(&State{
State: MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -842,7 +842,7 @@ func TestContext2Refresh_outputPartial(t *testing.T) {
func TestContext2Refresh_stateBasic(t *testing.T) {
p := testProvider("aws")
m := testModule(t, "refresh-basic")
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -904,7 +904,7 @@ func TestContext2Refresh_stateBasic(t *testing.T) {
func TestContext2Refresh_dataOrphan(t *testing.T) {
p := testProvider("null")
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -940,7 +940,7 @@ func TestContext2Refresh_dataOrphan(t *testing.T) {
func TestContext2Refresh_dataState(t *testing.T) {
m := testModule(t, "refresh-data-resource-basic")
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -1065,7 +1065,7 @@ func TestContext2Refresh_dataStateRefData(t *testing.T) {
}
m := testModule(t, "refresh-data-ref-data")
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -1111,7 +1111,7 @@ func TestContext2Refresh_dataStateRefData(t *testing.T) {
func TestContext2Refresh_tainted(t *testing.T) {
p := testProvider("aws")
m := testModule(t, "refresh-basic")
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -1176,7 +1176,7 @@ func TestContext2Refresh_unknownProvider(t *testing.T) {
ProviderResolver: providers.ResolverFixed(
map[string]providers.Factory{},
),
State: mustShimLegacyState(&State{
State: MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -1231,7 +1231,7 @@ func TestContext2Refresh_vars(t *testing.T) {
"aws": testProviderFuncFixed(p),
},
),
State: mustShimLegacyState(&State{
State: MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
@ -1311,7 +1311,7 @@ func TestContext2Refresh_orphanModule(t *testing.T) {
}
}
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -1461,7 +1461,7 @@ func TestContext2Refresh_noDiffHookOnScaleOut(t *testing.T) {
// we need to make DiffFn available to let that complete.
p.DiffFn = testDiffFn
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -1522,7 +1522,7 @@ func TestContext2Refresh_updateProviderInState(t *testing.T) {
p.DiffFn = testDiffFn
p.ApplyFn = testApplyFn
s := mustShimLegacyState(&State{
s := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,

View File

@ -780,40 +780,6 @@ func contextOptsForPlanViaFile(configSnap *configload.Snapshot, state *states.St
}, nil
}
// shimLegacyState is a helper that takes the legacy state type and
// converts it to the new state type.
//
// This is implemented as a state file upgrade, so it will not preserve
// parts of the state structure that are not included in a serialized state,
// such as the resolved results of any local values, outputs in non-root
// modules, etc.
func shimLegacyState(legacy *State) (*states.State, error) {
if legacy == nil {
return nil, nil
}
var buf bytes.Buffer
err := WriteState(legacy, &buf)
if err != nil {
return nil, err
}
f, err := statefile.Read(&buf)
if err != nil {
return nil, err
}
return f.State, err
}
// mustShimLegacyState is a wrapper around ShimLegacyState that panics if
// the conversion does not succeed. This is primarily intended for tests where
// the given legacy state is an object constructed within the test.
func mustShimLegacyState(legacy *State) *states.State {
ret, err := shimLegacyState(legacy)
if err != nil {
panic(err)
}
return ret
}
// legacyPlanComparisonString produces a string representation of the changes
// from a plan and a given state togther, as was formerly produced by the
// String method of terraform.Plan.

View File

@ -537,7 +537,7 @@ func TestContext2Validate_orphans(t *testing.T) {
}
m := testModule(t, "validate-good")
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -868,7 +868,7 @@ func TestContext2Validate_tainted(t *testing.T) {
}
m := testModule(t, "validate-good")
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -937,7 +937,7 @@ func TestContext2Validate_targetedDestroy(t *testing.T) {
Provisioners: map[string]ProvisionerFactory{
"shell": testProvisionerFuncFixed(pr),
},
State: mustShimLegacyState(&State{
State: MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,

View File

@ -152,7 +152,7 @@ func TestEvalReadState(t *testing.T) {
for k, c := range cases {
t.Run(k, func(t *testing.T) {
ctx := new(MockEvalContext)
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,

View File

@ -241,7 +241,7 @@ func TestApplyGraphBuilder_destroyStateOnly(t *testing.T) {
},
}
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: []string{"root", "child"},

View File

@ -11,7 +11,7 @@ func TestRefreshGraphBuilder_configOrphans(t *testing.T) {
m := testModule(t, "refresh-config-orphan")
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,

View File

@ -250,7 +250,7 @@ func TestModuleTreeDependencies(t *testing.T) {
root = testModule(t, test.ConfigDir)
}
got := ConfigTreeDependencies(root, mustShimLegacyState(test.State))
got := ConfigTreeDependencies(root, MustShimLegacyState(test.State))
for _, problem := range deep.Equal(got, test.Want) {
t.Error(problem)
}

View File

@ -11,7 +11,7 @@ import (
func TestNodeRefreshableDataResourceDynamicExpand_scaleOut(t *testing.T) {
m := testModule(t, "refresh-data-scale-inout")
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -78,7 +78,7 @@ root - terraform.graphNodeRoot
func TestNodeRefreshableDataResourceDynamicExpand_scaleIn(t *testing.T) {
m := testModule(t, "refresh-data-scale-inout")
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,

View File

@ -13,7 +13,7 @@ import (
func TestNodeRefreshableManagedResourceDynamicExpand_scaleOut(t *testing.T) {
m := testModule(t, "refresh-resource-scale-inout")
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
@ -78,7 +78,7 @@ root - terraform.graphNodeRoot
func TestNodeRefreshableManagedResourceDynamicExpand_scaleIn(t *testing.T) {
m := testModule(t, "refresh-resource-scale-inout")
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,

View File

@ -8,7 +8,7 @@ import (
)
func TestOrphanResourceCountTransformer(t *testing.T) {
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: []string{"root"},
@ -62,7 +62,7 @@ func TestOrphanResourceCountTransformer(t *testing.T) {
}
func TestOrphanResourceCountTransformer_zero(t *testing.T) {
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: []string{"root"},
@ -116,7 +116,7 @@ func TestOrphanResourceCountTransformer_zero(t *testing.T) {
}
func TestOrphanResourceCountTransformer_oneNoIndex(t *testing.T) {
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: []string{"root"},
@ -170,7 +170,7 @@ func TestOrphanResourceCountTransformer_oneNoIndex(t *testing.T) {
}
func TestOrphanResourceCountTransformer_oneIndex(t *testing.T) {
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: []string{"root"},
@ -224,7 +224,7 @@ func TestOrphanResourceCountTransformer_oneIndex(t *testing.T) {
}
func TestOrphanResourceCountTransformer_zeroAndNone(t *testing.T) {
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: []string{"root"},
@ -278,7 +278,7 @@ func TestOrphanResourceCountTransformer_zeroAndNone(t *testing.T) {
}
func TestOrphanResourceCountTransformer_zeroAndNoneCount(t *testing.T) {
state := mustShimLegacyState(&State{
state := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: []string{"root"},