MCPcopy
hub / github.com/caddyserver/caddy / TestDispenser_NextLine

Function TestDispenser_NextLine

caddyconfig/caddyfile/dispenser_test.go:110–138  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

108}
109
110func TestDispenser_NextLine(t *testing.T) {
111 input := `host:port
112 dir1 arg1
113 dir2 arg2 arg3`
114 d := NewTestDispenser(input)
115
116 assertNextLine := func(shouldLoad bool, expectedVal string, expectedCursor int) {
117 if d.NextLine() != shouldLoad {
118 t.Errorf("NextLine(): Should load token but got false instead (val: '%s')", d.Val())
119 }
120 if d.cursor != expectedCursor {
121 t.Errorf("NextLine(): Expected cursor to be %d, instead was %d", expectedCursor, d.cursor)
122 }
123 if val := d.Val(); val != expectedVal {
124 t.Errorf("Val(): Expected '%s' but got '%s'", expectedVal, val)
125 }
126 }
127
128 assertNextLine(true, "host:port", 0)
129 assertNextLine(true, "dir1", 1)
130 assertNextLine(false, "dir1", 1)
131 d.Next() // arg1
132 assertNextLine(true, "dir2", 3)
133 assertNextLine(false, "dir2", 3)
134 d.Next() // arg2
135 assertNextLine(false, "arg2", 4)
136 d.Next() // arg3
137 assertNextLine(false, "arg3", 5)
138}
139
140func TestDispenser_NextBlock(t *testing.T) {
141 input := `foobar1 {

Callers

nothing calls this directly

Calls 4

NewTestDispenserFunction · 0.85
NextLineMethod · 0.80
ValMethod · 0.80
NextMethod · 0.65

Tested by

no test coverage detected