2 more tests that weren't correct
Found 2 more tests that still had dangling empty modules, which are now fixed.
This commit is contained in:
parent
f915c5d957
commit
98cf28b02d
|
@ -2637,7 +2637,7 @@ func TestContext2Apply_orphanResource(t *testing.T) {
|
||||||
Type: "test_thing",
|
Type: "test_thing",
|
||||||
Name: "one",
|
Name: "one",
|
||||||
}.Absolute(addrs.RootModuleInstance)
|
}.Absolute(addrs.RootModuleInstance)
|
||||||
s.SetResourceMeta(oneAddr, states.EachList, providerAddr)
|
s.SetResourceProvider(oneAddr, providerAddr)
|
||||||
s.SetResourceInstanceCurrent(oneAddr.Instance(addrs.IntKey(0)), &states.ResourceInstanceObjectSrc{
|
s.SetResourceInstanceCurrent(oneAddr.Instance(addrs.IntKey(0)), &states.ResourceInstanceObjectSrc{
|
||||||
Status: states.ObjectReady,
|
Status: states.ObjectReady,
|
||||||
AttrsJSON: []byte(`{}`),
|
AttrsJSON: []byte(`{}`),
|
||||||
|
@ -6111,9 +6111,7 @@ func TestContext2Apply_destroyWithModuleVariableAndCount(t *testing.T) {
|
||||||
//Test that things were destroyed
|
//Test that things were destroyed
|
||||||
actual := strings.TrimSpace(state.String())
|
actual := strings.TrimSpace(state.String())
|
||||||
expected := strings.TrimSpace(`
|
expected := strings.TrimSpace(`
|
||||||
<no state>
|
<no state>`)
|
||||||
module.child:
|
|
||||||
<no state>`)
|
|
||||||
if actual != expected {
|
if actual != expected {
|
||||||
t.Fatalf("expected: \n%s\n\nbad: \n%s", expected, actual)
|
t.Fatalf("expected: \n%s\n\nbad: \n%s", expected, actual)
|
||||||
}
|
}
|
||||||
|
@ -6269,9 +6267,7 @@ func TestContext2Apply_destroyWithModuleVariableAndCountNested(t *testing.T) {
|
||||||
//Test that things were destroyed
|
//Test that things were destroyed
|
||||||
actual := strings.TrimSpace(state.String())
|
actual := strings.TrimSpace(state.String())
|
||||||
expected := strings.TrimSpace(`
|
expected := strings.TrimSpace(`
|
||||||
<no state>
|
<no state>`)
|
||||||
module.child.child2:
|
|
||||||
<no state>`)
|
|
||||||
if actual != expected {
|
if actual != expected {
|
||||||
t.Fatalf("expected: \n%s\n\nbad: \n%s", expected, actual)
|
t.Fatalf("expected: \n%s\n\nbad: \n%s", expected, actual)
|
||||||
}
|
}
|
||||||
|
|
|
@ -475,7 +475,7 @@ func (n *EvalWriteResourceState) Eval(ctx EvalContext) (interface{}, error) {
|
||||||
return nil, diags.Err()
|
return nil, diags.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
state.SetResourceMeta(n.Addr, states.EachList, n.ProviderAddr)
|
state.SetResourceProvider(n.Addr, n.ProviderAddr)
|
||||||
expander.SetResourceCount(n.Addr.Module, n.Addr.Resource, count)
|
expander.SetResourceCount(n.Addr.Module, n.Addr.Resource, count)
|
||||||
|
|
||||||
case n.Config.ForEach != nil:
|
case n.Config.ForEach != nil:
|
||||||
|
@ -487,11 +487,11 @@ func (n *EvalWriteResourceState) Eval(ctx EvalContext) (interface{}, error) {
|
||||||
|
|
||||||
// This method takes care of all of the business logic of updating this
|
// This method takes care of all of the business logic of updating this
|
||||||
// while ensuring that any existing instances are preserved, etc.
|
// while ensuring that any existing instances are preserved, etc.
|
||||||
state.SetResourceMeta(n.Addr, states.EachMap, n.ProviderAddr)
|
state.SetResourceProvider(n.Addr, n.ProviderAddr)
|
||||||
expander.SetResourceForEach(n.Addr.Module, n.Addr.Resource, forEach)
|
expander.SetResourceForEach(n.Addr.Module, n.Addr.Resource, forEach)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
state.SetResourceMeta(n.Addr, states.NoEach, n.ProviderAddr)
|
state.SetResourceProvider(n.Addr, n.ProviderAddr)
|
||||||
expander.SetResourceSingle(n.Addr.Module, n.Addr.Resource)
|
expander.SetResourceSingle(n.Addr.Module, n.Addr.Resource)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/agext/levenshtein"
|
"github.com/agext/levenshtein"
|
||||||
|
@ -803,43 +802,6 @@ func (d *evaluationStateData) getResourceSchema(addr addrs.Resource, providerAdd
|
||||||
return schema
|
return schema
|
||||||
}
|
}
|
||||||
|
|
||||||
// coerceInstanceKey attempts to convert the given key to the type expected
|
|
||||||
// for the given EachMode.
|
|
||||||
//
|
|
||||||
// If the key is already of the correct type or if it cannot be converted then
|
|
||||||
// it is returned verbatim. If conversion is required and possible, the
|
|
||||||
// converted value is returned. Callers should not try to determine if
|
|
||||||
// conversion was possible, should instead just check if the result is of
|
|
||||||
// the expected type.
|
|
||||||
func (d *evaluationStateData) coerceInstanceKey(key addrs.InstanceKey, mode states.EachMode) addrs.InstanceKey {
|
|
||||||
if key == addrs.NoKey {
|
|
||||||
// An absent key can't be converted
|
|
||||||
return key
|
|
||||||
}
|
|
||||||
|
|
||||||
switch mode {
|
|
||||||
case states.NoEach:
|
|
||||||
// No conversions possible at all
|
|
||||||
return key
|
|
||||||
case states.EachMap:
|
|
||||||
if intKey, isInt := key.(addrs.IntKey); isInt {
|
|
||||||
return addrs.StringKey(strconv.Itoa(int(intKey)))
|
|
||||||
}
|
|
||||||
return key
|
|
||||||
case states.EachList:
|
|
||||||
if strKey, isStr := key.(addrs.StringKey); isStr {
|
|
||||||
i, err := strconv.Atoi(string(strKey))
|
|
||||||
if err != nil {
|
|
||||||
return key
|
|
||||||
}
|
|
||||||
return addrs.IntKey(i)
|
|
||||||
}
|
|
||||||
return key
|
|
||||||
default:
|
|
||||||
return key
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d *evaluationStateData) GetTerraformAttr(addr addrs.TerraformAttr, rng tfdiags.SourceRange) (cty.Value, tfdiags.Diagnostics) {
|
func (d *evaluationStateData) GetTerraformAttr(addr addrs.TerraformAttr, rng tfdiags.SourceRange) (cty.Value, tfdiags.Diagnostics) {
|
||||||
var diags tfdiags.Diagnostics
|
var diags tfdiags.Diagnostics
|
||||||
switch addr.Name {
|
switch addr.Name {
|
||||||
|
|
Loading…
Reference in New Issue