Skip to content

Commit

Permalink
テストの silent packet 送信までの時間を伸ばす
Browse files Browse the repository at this point in the history
  • Loading branch information
Hexa committed Nov 29, 2024
1 parent e250093 commit c6c26fb
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestOpusPacketReader(t *testing.T) {
}

t.Run("success", func(t *testing.T) {
d := time.Duration(100) * time.Millisecond
d := time.Duration(3000) * time.Millisecond
r := readDumpFile(t, "testdata/000.jsonl", 0)
defer r.Close()

Expand All @@ -47,12 +47,12 @@ func TestOpusPacketReader(t *testing.T) {
assert.ErrorIs(t, err, io.EOF)
break
}
assert.Equal(t, buf[:n], []byte{0, 0, 0})
assert.Equal(t, []byte{0, 0, 0}, buf[:n])
}
})

t.Run("read error", func(t *testing.T) {
d := time.Duration(100) * time.Millisecond
d := time.Duration(3000) * time.Millisecond
errPacketRead := errors.New("packet read error")

r := NewErrReadCloser(errPacketRead)
Expand All @@ -66,12 +66,12 @@ func TestOpusPacketReader(t *testing.T) {
assert.ErrorIs(t, err, errPacketRead)
break
}
assert.Equal(t, buf[:n], []byte{255, 255, 254})
assert.Equal(t, []byte{255, 255, 254}, buf[:n])
}
})

t.Run("closed reader", func(t *testing.T) {
d := time.Duration(100) * time.Millisecond
d := time.Duration(3000) * time.Millisecond
r := readDumpFile(t, "testdata/dump.jsonl", 0)
r.Close()

Expand All @@ -81,17 +81,17 @@ func TestOpusPacketReader(t *testing.T) {
buf := make([]byte, FrameSize)
_, err := reader.Read(buf)
if err != nil {
assert.ErrorIs(t, err, io.ErrClosedPipe)
assert.ErrorIs(t, io.ErrClosedPipe, err)
break
}
}
})

t.Run("close reader", func(t *testing.T) {
d := time.Duration(100) * time.Millisecond
d := time.Duration(3000) * time.Millisecond
r := readDumpFile(t, "testdata/dump.jsonl", 0)
go func() {
time.Sleep(100 * time.Millisecond)
time.Sleep(3000 * time.Millisecond)
r.Close()
}()

Expand All @@ -101,7 +101,7 @@ func TestOpusPacketReader(t *testing.T) {
buf := make([]byte, FrameSize)
_, err := reader.Read(buf)
if err != nil {
assert.ErrorIs(t, err, io.EOF)
assert.ErrorIs(t, io.EOF, err)
break
}
}
Expand Down

0 comments on commit c6c26fb

Please sign in to comment.