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

Function TestLimitWriter

coderd/util/xio/limitwriter_test.go:13–140  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func TestLimitWriter(t *testing.T) {
14 t.Parallel()
15
16 type writeCase struct {
17 N int
18 ExpN int
19 Err bool
20 }
21
22 // testCases will do multiple writes to the same limit writer and check the output.
23 testCases := []struct {
24 Name string
25 L int64
26 Writes []writeCase
27 N int
28 ExpN int
29 }{
30 {
31 Name: "Empty",
32 L: 1000,
33 Writes: []writeCase{
34 // A few empty writes
35 {N: 0, ExpN: 0}, {N: 0, ExpN: 0}, {N: 0, ExpN: 0},
36 },
37 },
38 {
39 Name: "NotFull",
40 L: 1000,
41 Writes: []writeCase{
42 {N: 250, ExpN: 250},
43 {N: 250, ExpN: 250},
44 {N: 250, ExpN: 250},
45 },
46 },
47 {
48 Name: "Short",
49 L: 1000,
50 Writes: []writeCase{
51 {N: 250, ExpN: 250},
52 {N: 250, ExpN: 250},
53 {N: 250, ExpN: 250},
54 {N: 250, ExpN: 250},
55 {N: 250, ExpN: 0, Err: true},
56 },
57 },
58 {
59 Name: "Exact",
60 L: 1000,
61 Writes: []writeCase{
62 {
63 N: 1000,
64 ExpN: 1000,
65 },
66 {
67 N: 1000,
68 Err: true,
69 },
70 },

Callers

nothing calls this directly

Calls 8

WriteMethod · 0.95
NewLimitWriterFunction · 0.92
RunMethod · 0.65
ReadMethod · 0.65
WriteMethod · 0.65
EqualMethod · 0.45
ErrorMethod · 0.45
BytesMethod · 0.45

Tested by

no test coverage detected