summaryrefslogtreecommitdiff
path: root/pkg/util/io_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/util/io_test.go')
-rw-r--r--pkg/util/io_test.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/pkg/util/io_test.go b/pkg/util/io_test.go
new file mode 100644
index 0000000..9d63e5d
--- /dev/null
+++ b/pkg/util/io_test.go
@@ -0,0 +1,24 @@
+package util
+
+import (
+ "bytes"
+ "context"
+ "testing"
+ "time"
+)
+
+func TestChannelReader(t *testing.T) {
+ ctx, cancel := context.WithTimeout(context.Background(), time.Second)
+ defer cancel()
+ b := []byte{1, 2, 3, 4, 5, 6, 7, 8}
+ reader := NewChannelReader(ctx, bytes.NewReader(b))
+
+ select {
+ case data := <-reader.Out:
+ if !bytes.Equal(b, data) {
+ t.Errorf("TestChannelReader() %v != %v", b, data)
+ }
+ case err := <-reader.Err:
+ t.Errorf("TestChannelReader() err = %v", err)
+ }
+}