snapshot of https://github.com/ThreeDotsLabs/watermill.git (master, 2026-09-15; blobs > 131072B omitted)
Some checks failed
master / ci (push) Failing after 0s

This commit is contained in:
upstream-mirror
2026-09-15 21:27:46 +05:00
commit ce933d1277
538 changed files with 46504 additions and 0 deletions

57
internal/channel_test.go Normal file
View File

@@ -0,0 +1,57 @@
package internal_test
import (
"testing"
"github.com/ThreeDotsLabs/watermill/internal"
"github.com/stretchr/testify/assert"
)
func TestIsChannelClosed(t *testing.T) {
closed := make(chan struct{})
close(closed)
withSentValue := make(chan struct{}, 1)
withSentValue <- struct{}{}
testCases := []struct {
Name string
Channel chan struct{}
ExpectedPanic bool
ExpectedClosed bool
}{
{
Name: "not_closed",
Channel: make(chan struct{}),
ExpectedPanic: false,
ExpectedClosed: false,
},
{
Name: "closed",
Channel: closed,
ExpectedPanic: false,
ExpectedClosed: true,
},
{
Name: "with_sent_value",
Channel: withSentValue,
ExpectedPanic: true,
ExpectedClosed: false,
},
}
for _, c := range testCases {
t.Run(c.Name, func(t *testing.T) {
testFunc := func() {
closed := internal.IsChannelClosed(c.Channel)
assert.EqualValues(t, c.ExpectedClosed, closed)
}
if c.ExpectedPanic {
assert.Panics(t, testFunc)
} else {
assert.NotPanics(t, testFunc)
}
})
}
}