Merge pull request #9525 from hashicorp/b-shadow-block

helper/shadow: keyedValue.WaitForChange must unlock
pull/9528/head
Mitchell Hashimoto 10 years ago committed by GitHub
commit ab36666653

@ -58,6 +58,7 @@ func (w *KeyedValue) WaitForChange(k string) interface{} {
// If we're closed, we're closed
if w.closed {
w.lock.Unlock()
return ErrClosed
}

@ -312,3 +312,25 @@ func TestKeyedValueWaitForChange_closed(t *testing.T) {
t.Fatalf("bad: %#v", val)
}
}
func TestKeyedValueWaitForChange_closedFirst(t *testing.T) {
var v KeyedValue
// Close
v.Close()
// Verify
val := v.WaitForChange("foo")
if val != ErrClosed {
t.Fatalf("bad: %#v", val)
}
// Set a value
v.SetValue("foo", 42)
// Try again
val = v.WaitForChange("foo")
if val != ErrClosed {
t.Fatalf("bad: %#v", val)
}
}

Loading…
Cancel
Save