Merge pull request #9525 from hashicorp/b-shadow-block
helper/shadow: keyedValue.WaitForChange must unlock
This commit is contained in:
commit
ab36666653
|
@ -58,6 +58,7 @@ func (w *KeyedValue) WaitForChange(k string) interface{} {
|
||||||
|
|
||||||
// If we're closed, we're closed
|
// If we're closed, we're closed
|
||||||
if w.closed {
|
if w.closed {
|
||||||
|
w.lock.Unlock()
|
||||||
return ErrClosed
|
return ErrClosed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -312,3 +312,25 @@ func TestKeyedValueWaitForChange_closed(t *testing.T) {
|
||||||
t.Fatalf("bad: %#v", val)
|
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…
Reference in New Issue