helper/shadow: keyedValue.WaitForChange must unlock
This commit is contained in:
parent
f8e35ecb2f
commit
de827887bf
|
@ -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…
Reference in New Issue