From f8b8f3a666d816071e7e30e2e1eeec8a29ab3d86 Mon Sep 17 00:00:00 2001 From: jochen Date: Thu, 22 Oct 2026 17:45:58 +0200 Subject: [PATCH] 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 --- go/process/state_integration_test.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/go/process/state_integration_test.go b/go/process/state_integration_test.go index eca097a..32c1e72 100644 --- a/go/process/state_integration_test.go +++ b/go/process/state_integration_test.go @@ -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)