MCPcopy Index your code
hub / github.com/coder/coder / TestCoordinateResponse_Chunked

Function TestCoordinateResponse_Chunked

tailnet/proto/response_test.go:11–55  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestCoordinateResponse_Chunked(t *testing.T) {
12 t.Parallel()
13
14 t.Run("NoChunkingNeeded", func(t *testing.T) {
15 t.Parallel()
16 resp := &proto.CoordinateResponse{
17 PeerUpdates: make([]*proto.CoordinateResponse_PeerUpdate, 100),
18 }
19 chunks := resp.Chunked()
20 require.Len(t, chunks, 1)
21 require.Equal(t, resp, chunks[0])
22 })
23
24 t.Run("ExactLimit", func(t *testing.T) {
25 t.Parallel()
26 resp := &proto.CoordinateResponse{
27 PeerUpdates: make([]*proto.CoordinateResponse_PeerUpdate, 1024),
28 }
29 chunks := resp.Chunked()
30 require.Len(t, chunks, 1)
31 require.Equal(t, resp, chunks[0])
32 })
33
34 t.Run("MultipleChunks", func(t *testing.T) {
35 t.Parallel()
36 n := 1024*3 + 500
37 resp := &proto.CoordinateResponse{
38 PeerUpdates: make([]*proto.CoordinateResponse_PeerUpdate, n),
39 }
40 chunks := resp.Chunked()
41 require.Len(t, chunks, 4)
42 total := 0
43 for _, c := range chunks {
44 total += len(c.GetPeerUpdates())
45 }
46 require.Equal(t, n, total)
47 })
48
49 t.Run("EmptyResponse", func(t *testing.T) {
50 t.Parallel()
51 resp := &proto.CoordinateResponse{}
52 chunks := resp.Chunked()
53 require.Len(t, chunks, 1)
54 })
55}

Callers

nothing calls this directly

Calls 5

ChunkedMethod · 0.95
GetPeerUpdatesMethod · 0.80
RunMethod · 0.65
LenMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected