summaryrefslogtreecommitdiff
path: root/pkg/util/io_test.go
diff options
context:
space:
mode:
authorKyren223 <ulmliad223@gmail.com>2024-10-20 11:36:43 +0300
committerKyren223 <ulmliad223@gmail.com>2024-10-20 11:36:43 +0300
commit1997bc8a150b92783060cc7129e1ee72a761182b (patch)
tree35d4df750feb2f1f36883ce8d7f2da9a72c59a25 /pkg/util/io_test.go
parent6e6ca1d7a10a3a4a1decbdb78e2ea11ce24974e3 (diff)
refactor: mid refactor
Diffstat (limited to 'pkg/util/io_test.go')
-rw-r--r--pkg/util/io_test.go59
1 files changed, 0 insertions, 59 deletions
diff --git a/pkg/util/io_test.go b/pkg/util/io_test.go
deleted file mode 100644
index f05b833..0000000
--- a/pkg/util/io_test.go
+++ /dev/null
@@ -1,59 +0,0 @@
-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("%v != %v", b, data)
- }
- case err := <-reader.Err:
- t.Errorf("reading err: %v", err)
- }
-}
-
-func TestChannelReaderMultiPartRead(t *testing.T) {
- ctx, cancel := context.WithTimeout(context.Background(), time.Second)
- defer cancel()
-
- b := []byte("Testing FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting FramerTesting Framer")
- b1 := b[:512]
- b2 := b[512:]
- reader := NewChannelReader(ctx, bytes.NewReader(b))
-
- counter := 0
-outer:
- for {
- select {
- case data := <-reader.Out:
- if counter == 0 {
- if !bytes.Equal(b1, data) {
- t.Errorf("%v != %v", b, data)
- }
- } else {
- if !bytes.Equal(b2[:len(data)], data) {
- t.Errorf("%v != %v", b, data)
- }
- }
- counter++
- if counter == 2 {
- break outer
- }
-
- case err := <-reader.Err:
- t.Errorf("reading err: %v", err)
- break outer
- }
- }
-}