mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-09 07:05:33 -06:00
terraform: more state tests, fix a bug
This commit is contained in:
parent
cc8e6b6331
commit
57f7507ebd
@ -172,6 +172,9 @@ func (s *State) Equal(other *State) bool {
|
||||
}
|
||||
|
||||
// If any of the modules are not equal, then this state isn't equal
|
||||
if len(s.Modules) != len(other.Modules) {
|
||||
return false
|
||||
}
|
||||
for _, m := range s.Modules {
|
||||
// This isn't very optimal currently but works.
|
||||
otherM := other.ModuleByPath(m.Path)
|
||||
|
@ -116,6 +116,19 @@ func TestStateEqual(t *testing.T) {
|
||||
Result bool
|
||||
One, Two *State
|
||||
}{
|
||||
// Nils
|
||||
{
|
||||
false,
|
||||
nil,
|
||||
&State{Version: 2},
|
||||
},
|
||||
|
||||
{
|
||||
true,
|
||||
nil,
|
||||
nil,
|
||||
},
|
||||
|
||||
// Different versions
|
||||
{
|
||||
false,
|
||||
@ -159,6 +172,9 @@ func TestStateEqual(t *testing.T) {
|
||||
if tc.One.Equal(tc.Two) != tc.Result {
|
||||
t.Fatalf("Bad: %d\n\n%s\n\n%s", i, tc.One.String(), tc.Two.String())
|
||||
}
|
||||
if tc.Two.Equal(tc.One) != tc.Result {
|
||||
t.Fatalf("Bad: %d\n\n%s\n\n%s", i, tc.One.String(), tc.Two.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user