terraform: more state tests, fix a bug

This commit is contained in:
Mitchell Hashimoto 2015-02-23 21:43:54 -08:00
parent cc8e6b6331
commit 57f7507ebd
2 changed files with 19 additions and 0 deletions

View File

@ -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)

View File

@ -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())
}
}
}