core: Fix TestContext2Apply_outputOrphanModule

The adaptation of ModuleState.RemovedOutputs for the new config types
was incorrect because it took the absence of any output map as "nothing to
do", rather than "everything has been removed" as expected.

Now it treats a nil map like an empty map, detecting _all_ of the outputs
as having been removed if the output map is nil.
This commit is contained in:
Martin Atkins 2018-05-29 16:56:00 -07:00
parent 11bd07abb2
commit aedbbc6207
2 changed files with 7 additions and 3 deletions

View File

@ -4110,7 +4110,7 @@ func TestContext2Apply_outputOrphanModule(t *testing.T) {
actual = strings.TrimSpace(state.String())
if actual != "" {
t.Fatalf("expected no state, got:\n%s", actual)
t.Fatalf("wrong result\n\ngot:\n%s\n\nwant: no state at all", actual)
}
}

View File

@ -1086,9 +1086,13 @@ func (m *ModuleState) Orphans(c *configs.Module) []addrs.ResourceInstance {
// RemovedOutputs returns a list of outputs that are in the State but aren't
// present in the configuration itself.
func (s *ModuleState) RemovedOutputs(outputs map[string]*configs.Output) []addrs.OutputValue {
if len(outputs) == 0 {
return nil
if outputs == nil {
// If we got no output map at all then we'll just treat our set of
// configured outputs as empty, since that suggests that they've all
// been removed by removing their containing module.
outputs = make(map[string]*configs.Output)
}
s.Lock()
defer s.Unlock()