notify/stream_config_public_test.go

56 lines
1.9 KiB
Go
Raw Normal View History

package notify
import "testing"
func TestClientStreamConfigPublicAPI(t *testing.T) {
client := NewClient().(*ClientCommon)
client.SetStreamConfig(StreamConfig{
ChunkSize: 1024,
InboundQueueLimit: 16,
InboundBufferedBytesLimit: 32 * 1024,
OutboundWindowBytes: 128 * 1024,
OutboundMaxInFlightChunks: 4,
})
cfg := client.GetStreamConfig()
if got, want := cfg.ChunkSize, 1024; got != want {
t.Fatalf("chunk size = %d, want %d", got, want)
}
if got, want := cfg.InboundQueueLimit, 16; got != want {
t.Fatalf("queue limit = %d, want %d", got, want)
}
if got, want := cfg.InboundBufferedBytesLimit, 32*1024; got != want {
t.Fatalf("buffered limit = %d, want %d", got, want)
}
if got, want := cfg.OutboundWindowBytes, 128*1024; got != want {
t.Fatalf("outbound window = %d, want %d", got, want)
}
if got, want := cfg.OutboundMaxInFlightChunks, 4; got != want {
t.Fatalf("outbound max inflight chunks = %d, want %d", got, want)
}
}
func TestServerStreamConfigPublicAPINormalizesDefaults(t *testing.T) {
server := NewServer().(*ServerCommon)
server.SetStreamConfig(StreamConfig{})
cfg := server.GetStreamConfig()
if got, want := cfg.ChunkSize, defaultFileChunkSize; got != want {
t.Fatalf("chunk size = %d, want %d", got, want)
}
if got, want := cfg.InboundQueueLimit, defaultStreamInboundQueueLimit; got != want {
t.Fatalf("queue limit = %d, want %d", got, want)
}
if got, want := cfg.InboundBufferedBytesLimit, defaultStreamInboundBufferedBytesLimit; got != want {
t.Fatalf("buffered limit = %d, want %d", got, want)
}
if got, want := cfg.OutboundWindowBytes, defaultStreamOutboundWindowBytes; got != want {
t.Fatalf("outbound window = %d, want %d", got, want)
}
if got, want := cfg.OutboundMaxInFlightChunks, defaultStreamOutboundMaxInFlightChunks; got != want {
t.Fatalf("outbound max inflight chunks = %d, want %d", got, want)
}
}