Skip to content

Test icingaredis.SetChecksums()#799

Merged
oxzi merged 1 commit intomainfrom
TestSetChecksums
Jan 9, 2026
Merged

Test icingaredis.SetChecksums()#799
oxzi merged 1 commit intomainfrom
TestSetChecksums

Conversation

@Al2Klimov
Copy link
Member

No description provided.

@cla-bot cla-bot bot added the cla/signed label Sep 5, 2024
@Al2Klimov Al2Klimov requested a review from oxzi September 6, 2024 11:45
Copy link
Member

@oxzi oxzi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For both functions, tests against a prematurely canceled context are missing.

select {
case <-time.After(l.latency):
case <-ctx.Done():
return
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation depth eleven. We're hitting indentation levels that shouldn't even be possible :>

@Al2Klimov
Copy link
Member Author

If the input channel blocks since its creation forever and the context has always been canceled, do you expect the output channel to get closed immediately?

--- pkg/icingaredis/utils_test.go
+++ pkg/icingaredis/utils_test.go
@@ -346,4 +346,29 @@ func TestSetChecksums(t *testing.T) {
                        }
                })
        }
+
+       t.Run("cancel-ctx", func(t *testing.T) {
+               ctx, cancel := context.WithCancel(context.Background())
+               cancel()
+
+               output, errs := SetChecksums(ctx, make(chan database.Entity), map[string]database.Entity{}, 1)
+
+               require.NotNil(t, output, "output channel should not be nil")
+               require.NotNil(t, errs, "error channel should not be nil")
+
+               select {
+               case v, ok := <-output:
+                       require.False(t, ok, "output channel should be closed, got %#v", v)
+               case <-time.After(time.Second):
+                       require.Fail(t, "output channel should not block")
+               }
+
+               select {
+               case err, ok := <-errs:
+                       require.True(t, ok, "error channel should not be closed, yet")
+                       require.Error(t, err)
+               case <-time.After(time.Second):
+                       require.Fail(t, "error channel should not block")
+               }
+       })
 }

@oxzi
Copy link
Member

oxzi commented Sep 24, 2024

If the input channel blocks since its creation forever and the context has always been canceled, do you expect the output channel to get closed immediately?

I guess so, yes. However, the current implementation should skip closing the output channel, as it happens deferred in the errgroup goroutine.

@Al2Klimov Al2Klimov self-assigned this Sep 27, 2024
@Al2Klimov Al2Klimov removed their assignment Aug 20, 2025
@Al2Klimov Al2Klimov requested a review from oxzi August 20, 2025 11:16
@Al2Klimov Al2Klimov force-pushed the TestSetChecksums branch 2 times, most recently from ab60c73 to 8052ede Compare November 7, 2025 16:56
@oxzi oxzi self-assigned this Jan 9, 2026
@oxzi oxzi added this to the 1.5.2 milestone Jan 9, 2026
@oxzi oxzi force-pushed the TestSetChecksums branch from 8052ede to b29fa56 Compare January 9, 2026 09:24
Copy link
Member

@oxzi oxzi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have rebased the PR branch onto main.

In general, looks mergeable to me, thanks.

@oxzi oxzi enabled auto-merge January 9, 2026 09:25
@oxzi oxzi removed their assignment Jan 9, 2026
@oxzi oxzi merged commit 8b64be8 into main Jan 9, 2026
31 checks passed
@oxzi oxzi deleted the TestSetChecksums branch January 9, 2026 09:34
@oxzi oxzi mentioned this pull request Jan 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants