network/frame/close_stream_frame_test.go

21 lines
514 B
Go
Raw Permalink Normal View History

2023-04-05 16:15:59 +08:00
package frame
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestCloseStreamFrame(t *testing.T) {
f := NewCloseStreamFrame("eeffgg", "aabbcc")
bytes := f.Encode()
assert.Equal(t, []byte{0x94, 0x10, 0x15, 0x6, 0x65, 0x65, 0x66, 0x66, 0x67, 0x67, 0x16, 0x6, 0x61, 0x61, 0x62, 0x62, 0x63, 0x63}, bytes)
got, err := DecodeToCloseStreamFrame(bytes)
assert.Equal(t, f, got)
assert.NoError(t, err)
assert.EqualValues(t, "eeffgg", f.StreamID())
assert.EqualValues(t, "aabbcc", f.Reason())
}