issue 1840/S2: take a narrowed watch's current values as a set, since the bus hands them in the order of their last revision
This commit is contained in:
@@ -180,6 +180,18 @@ func TestStateWatchOnAGrantedBucket(t *testing.T) {
|
||||
if len(narrow) != 2 {
|
||||
t.Fatalf("a narrowed watch handed %d current values, want 2", len(narrow))
|
||||
}
|
||||
// the current values come in the order of their last revision, not of their keys: taken as a set.
|
||||
narrowCurrent := map[string]bool{}
|
||||
for len(narrow) > 0 {
|
||||
c := <-narrow
|
||||
if !c.Current || c.Op != "put" {
|
||||
t.Fatalf("a narrowed watch's current value arrived as %+v", c)
|
||||
}
|
||||
narrowCurrent[c.Key] = true
|
||||
}
|
||||
if !narrowCurrent["a.x"] || !narrowCurrent["a.y"] {
|
||||
t.Fatalf("a narrowed watch's current values %v, want a.x and a.y", narrowCurrent)
|
||||
}
|
||||
|
||||
if _, err := s.Put("a.x", 5); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -203,8 +215,8 @@ func TestStateWatchOnAGrantedBucket(t *testing.T) {
|
||||
for _, want := range []string{"a.x", "a.y"} {
|
||||
select {
|
||||
case c := <-narrow:
|
||||
if c.Key != want {
|
||||
t.Fatalf("narrowed watch got %+v, want %s", c, want)
|
||||
if c.Key != want || c.Current {
|
||||
t.Fatalf("narrowed watch got %+v, want the change of %s", c, want)
|
||||
}
|
||||
case <-time.After(10 * time.Second):
|
||||
t.Fatalf("narrowed watch missed %s", want)
|
||||
|
||||
Reference in New Issue
Block a user