mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
Set and single test coverage
This commit is contained in:
parent
a5c5d2c28c
commit
a1a46425bd
@ -974,15 +974,12 @@ func getValMarks(schema *configschema.Block, val cty.Value, path cty.Path) []cty
|
|||||||
switch blockS.Nesting {
|
switch blockS.Nesting {
|
||||||
case configschema.NestingSingle, configschema.NestingGroup:
|
case configschema.NestingSingle, configschema.NestingGroup:
|
||||||
pvm = append(pvm, getValMarks(&blockS.Block, blockV, blockPath)...)
|
pvm = append(pvm, getValMarks(&blockS.Block, blockV, blockPath)...)
|
||||||
case configschema.NestingList, configschema.NestingMap:
|
case configschema.NestingList, configschema.NestingMap, configschema.NestingSet:
|
||||||
for it := blockV.ElementIterator(); it.Next(); {
|
for it := blockV.ElementIterator(); it.Next(); {
|
||||||
idx, blockEV := it.Element()
|
idx, blockEV := it.Element()
|
||||||
morePaths := getValMarks(&blockS.Block, blockEV, append(blockPath, cty.IndexStep{Key: idx}))
|
morePaths := getValMarks(&blockS.Block, blockEV, append(blockPath, cty.IndexStep{Key: idx}))
|
||||||
pvm = append(pvm, morePaths...)
|
pvm = append(pvm, morePaths...)
|
||||||
}
|
}
|
||||||
case configschema.NestingSet:
|
|
||||||
// TODO
|
|
||||||
continue
|
|
||||||
default:
|
default:
|
||||||
panic(fmt.Sprintf("unsupported nesting mode %s", blockS.Nesting))
|
panic(fmt.Sprintf("unsupported nesting mode %s", blockS.Nesting))
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ func TestEvaluatorGetResource(t *testing.T) {
|
|||||||
}.Instance(addrs.NoKey).Absolute(addrs.RootModuleInstance),
|
}.Instance(addrs.NoKey).Absolute(addrs.RootModuleInstance),
|
||||||
&states.ResourceInstanceObjectSrc{
|
&states.ResourceInstanceObjectSrc{
|
||||||
Status: states.ObjectReady,
|
Status: states.ObjectReady,
|
||||||
AttrsJSON: []byte(`{"id":"foo", "nesting_list": [{"sensitive_value":"abc"}], "nesting_map": {"foo":{"foo":"x"}}, "value":"hello"}`),
|
AttrsJSON: []byte(`{"id":"foo", "nesting_list": [{"sensitive_value":"abc"}], "nesting_map": {"foo":{"foo":"x"}}, "nesting_set": [{"baz":"abc"}], "nesting_single": {"boop":"abc"}, "value":"hello"}`),
|
||||||
},
|
},
|
||||||
addrs.AbsProviderConfig{
|
addrs.AbsProviderConfig{
|
||||||
Provider: addrs.NewDefaultProvider("test"),
|
Provider: addrs.NewDefaultProvider("test"),
|
||||||
@ -206,6 +206,22 @@ func TestEvaluatorGetResource(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Nesting: configschema.NestingMap,
|
Nesting: configschema.NestingMap,
|
||||||
},
|
},
|
||||||
|
"nesting_set": {
|
||||||
|
Block: configschema.Block{
|
||||||
|
Attributes: map[string]*configschema.Attribute{
|
||||||
|
"baz": {Type: cty.String, Optional: true, Sensitive: true},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Nesting: configschema.NestingSet,
|
||||||
|
},
|
||||||
|
"nesting_single": {
|
||||||
|
Block: configschema.Block{
|
||||||
|
Attributes: map[string]*configschema.Attribute{
|
||||||
|
"boop": {Type: cty.String, Optional: true, Sensitive: true},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Nesting: configschema.NestingSingle,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -230,6 +246,14 @@ func TestEvaluatorGetResource(t *testing.T) {
|
|||||||
"nesting_map": cty.MapVal(map[string]cty.Value{
|
"nesting_map": cty.MapVal(map[string]cty.Value{
|
||||||
"foo": cty.ObjectVal(map[string]cty.Value{"foo": cty.StringVal("x").Mark("sensitive")}),
|
"foo": cty.ObjectVal(map[string]cty.Value{"foo": cty.StringVal("x").Mark("sensitive")}),
|
||||||
}),
|
}),
|
||||||
|
"nesting_set": cty.SetVal([]cty.Value{
|
||||||
|
cty.ObjectVal(map[string]cty.Value{
|
||||||
|
"baz": cty.StringVal("abc").Mark("sensitive"),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
"nesting_single": cty.ObjectVal(map[string]cty.Value{
|
||||||
|
"boop": cty.StringVal("abc").Mark("sensitive"),
|
||||||
|
}),
|
||||||
"value": cty.StringVal("hello").Mark("sensitive"),
|
"value": cty.StringVal("hello").Mark("sensitive"),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user