From 96eee1bbed37f97ae5c0e144e7c08387e9024e2b Mon Sep 17 00:00:00 2001 From: Yun Wang Date: Thu, 27 Aug 2026 14:49:20 +0200 Subject: [PATCH] test: re-read instead of trusting the partial-update write response PartialUpdateChannel asserted the custom field straight off the UpdateChannelPartial response, which the server can hydrate from a read replica that has not observed the write. That made it the longest-running flake in this suite: it failed on main in the runs for #137 and #142, and again after the unset half was fixed, this time on the set half instead. The unset half already re-reads with require.Eventually for exactly this reason. The set half now does the same, so both halves are symmetric and neither depends on read-after-write. No coverage is lost. Asserting the value still catches a Set map serialized under the wrong key or a Custom map that fails to deserialize, which is the bug this test exists for, and the write response and GetOrCreate deserialize the same ChannelResponse type. Only the assumption that the write response is immediately consistent is gone. --- chat_channel_integration_test.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/chat_channel_integration_test.go b/chat_channel_integration_test.go index 0223047..9f9ff13 100644 --- a/chat_channel_integration_test.go +++ b/chat_channel_integration_test.go @@ -126,7 +126,16 @@ func TestChatChannelIntegration(t *testing.T) { }) require.NoError(t, err) require.NotNil(t, resp.Data.Channel) - assert.Equal(t, "red", resp.Data.Channel.Custom["color"]) + + // Same read-replica caveat as the unset below: assert that the write + // applied by re-reading, not from the write response. + require.Eventually(t, func() bool { + resp, err := ch.GetOrCreate(ctx, &GetOrCreateChannelRequest{}) + if err != nil || resp.Data.Channel == nil { + return false + } + return resp.Data.Channel.Custom["color"] == "red" + }, 5*time.Second, 500*time.Millisecond, "color should be set to red") // Unset fields _, err = ch.UpdateChannelPartial(ctx, &UpdateChannelPartialRequest{