MCPcopy
hub / github.com/davyxu/cellnet / TestPrintPage

Function TestPrintPage

tests/httppage_test.go:17–41  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

15const pageAddress = "127.0.0.1:10087"
16
17func TestPrintPage(t *testing.T) {
18
19 p := peer.NewGenericPeer("http.Acceptor", "httpserver", pageAddress, nil)
20
21 proc.BindProcessorHandler(p, "http", func(raw cellnet.Event) {
22
23 switch {
24 case raw.Session().(httppeer.RequestMatcher).Match("GET", "/"):
25
26 raw.Session().Send(&httppeer.HTMLRespond{
27 StatusCode: http.StatusOK,
28 PageTemplate: "index",
29 TemplateModel: "world",
30 })
31 }
32
33 })
34
35 p.Start()
36
37 validPage(t, fmt.Sprintf("http://%s", pageAddress), "<h1>Hello world</h1>")
38
39 p.Stop()
40
41}
42
43func validPage(t *testing.T, url, expectAck string) {
44 c := &http.Client{

Callers

nothing calls this directly

Calls 8

NewGenericPeerFunction · 0.92
BindProcessorHandlerFunction · 0.92
validPageFunction · 0.85
MatchMethod · 0.65
SessionMethod · 0.65
SendMethod · 0.65
StartMethod · 0.65
StopMethod · 0.65

Tested by

no test coverage detected