summaryrefslogtreecommitdiff
path: root/utilities/utilities_test.go
diff options
context:
space:
mode:
authorWill Hawkins <[email protected]>2022-07-02 01:01:08 -0400
committerWill Hawkins <[email protected]>2022-07-02 01:01:08 -0400
commitf0a9f4a3a50b63127a5e3d4ab2bdda3bbe4d8d0d (patch)
tree2d5fbaac26a35e663beb89d7b96a7085aaadeb3b /utilities/utilities_test.go
parent793a53ece7fd16cd52735c12f47584c438e1a58b (diff)
[Feature] Support spec v2 3/n
Diffstat (limited to 'utilities/utilities_test.go')
-rw-r--r--utilities/utilities_test.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/utilities/utilities_test.go b/utilities/utilities_test.go
new file mode 100644
index 0000000..72a11fb
--- /dev/null
+++ b/utilities/utilities_test.go
@@ -0,0 +1,39 @@
+package utilities
+
+import (
+ "sync"
+ "testing"
+ "time"
+)
+
+func TestReadAfterCloseOnBufferedChannel(t *testing.T) {
+ communication := make(chan int, 100)
+
+ maxC := 0
+
+ wg := sync.WaitGroup{}
+ wg.Add(2)
+
+ go func() {
+ counter := 0
+ for range make([]int, 50) {
+ communication <- counter
+ counter++
+ }
+ close(communication)
+ wg.Done()
+ }()
+
+ go func() {
+ time.Sleep(2 * time.Second)
+ for c := range communication {
+ maxC = c
+ }
+ wg.Done()
+ }()
+
+ wg.Wait()
+ if maxC != 49 {
+ t.Fatalf("Did not read all sent items from a buffered channel after channel.")
+ }
+}