MCPcopy
hub / github.com/probelabs/goreplay / TestMiddlewareWithPrettify

Function TestMiddlewareWithPrettify

middleware_test.go:130–154  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

128}
129
130func TestMiddlewareWithPrettify(t *testing.T) {
131 Settings.PrettifyHTTP = true
132 quit := make(chan struct{})
133 in := NewTestInput()
134 cmd, cancl := initCmd(echoSh, noDebug)
135 midd := initMiddleware(cmd, cancl, in, func(err error) {})
136 var b1 = []byte("POST / HTTP/1.1\r\nHost: example.org\r\nTransfer-Encoding: chunked\r\n\r\n4\r\nWiki\r\n5\r\npedia\r\nE\r\n in\r\n\r\nchunks.\r\n0\r\n\r\n")
137 var b2 = []byte("POST / HTTP/1.1\r\nHost: example.org\r\nContent-Length: 25\r\n\r\nWikipedia in\r\n\r\nchunks.")
138 out := NewTestOutput(func(msg *Message) {
139 if !bytes.Equal(proto.Body(b2), proto.Body(msg.Data)) {
140 t.Errorf("expected %q body to equal %q body", b2, msg.Data)
141 }
142 quit <- struct{}{}
143 })
144 pl := &InOutPlugins{}
145 pl.Inputs = []PluginReader{midd, in}
146 pl.Outputs = []PluginWriter{out}
147 pl.All = []interface{}{midd, out, in}
148 e := NewEmitter()
149 go e.Start(pl, "")
150 in.EmitBytes(b1)
151 <-quit
152 midd.Close()
153 Settings.PrettifyHTTP = false
154}

Callers

nothing calls this directly

Calls 9

StartMethod · 0.95
EmitBytesMethod · 0.95
BodyFunction · 0.92
NewTestInputFunction · 0.85
initCmdFunction · 0.85
initMiddlewareFunction · 0.85
NewTestOutputFunction · 0.85
NewEmitterFunction · 0.85
CloseMethod · 0.65

Tested by

no test coverage detected