terraform: Refresh tests passing

This commit is contained in:
Mitchell Hashimoto 2014-09-17 16:51:07 -07:00
parent e2aa067996
commit f9ce7de468
2 changed files with 6 additions and 6 deletions

View File

@ -889,13 +889,12 @@ func (c *Context) refreshWalkFn() depgraph.WalkFunc {
}
c.sl.Lock()
// TODO: Handle other moduels
// TODO: Handle other modules
mod := c.state.RootModule()
if len(r.State.Tainted) == 0 && (is == nil || is.ID == "") {
delete(mod.Resources, r.Id)
} else {
mod.Resources[r.Id] = r.State
mod.Resources[r.Id].Primary = is
}
c.sl.Unlock()

View File

@ -2162,14 +2162,15 @@ func TestContextRefresh_state(t *testing.T) {
if err != nil {
t.Fatalf("err: %s", err)
}
originalMod := state.RootModule()
mod := s.RootModule()
if !p.RefreshCalled {
t.Fatal("refresh should be called")
}
if !reflect.DeepEqual(p.RefreshState, mod.Resources["aws_instance.web"]) {
if !reflect.DeepEqual(p.RefreshState, originalMod.Resources["aws_instance.web"].Primary) {
t.Fatalf("bad: %#v", p.RefreshState)
}
if !reflect.DeepEqual(mod.Resources["aws_instance.web"], p.RefreshReturn) {
if !reflect.DeepEqual(mod.Resources["aws_instance.web"].Primary, p.RefreshReturn) {
t.Fatalf("bad: %#v", mod.Resources)
}
}
@ -2216,7 +2217,7 @@ func TestContextRefresh_vars(t *testing.T) {
if p.RefreshState.ID != "foo" {
t.Fatalf("bad: %#v", p.RefreshState)
}
if !reflect.DeepEqual(mod.Resources["aws_instance.web"], p.RefreshReturn) {
if !reflect.DeepEqual(mod.Resources["aws_instance.web"].Primary, p.RefreshReturn) {
t.Fatalf("bad: %#v", mod.Resources["aws_instance.web"])
}