示例#1
0
func TestPing(t *testing.T) {
	router := httpd.NewRouter()
	config := httpd.Config{BindAddress: "127.0.0.1:0"}
	_ = controllers.NewPingController(router, config.LogEnabled, config.WriteTracing)

	res := httptest.NewRecorder()
	req, _ := http.NewRequest("GET", "http://example.com/ping", nil)

	router.ServeHTTP(res, req)

	expect(t, res.Code, http.StatusOK)
	expect(t, res.Body.String(), "{\"result\":\"pong\"}\n")
}
示例#2
0
func (s *Service) setupPingController(config Config) *controllers.PingController {
	c := controllers.NewPingController(s.router, config.LogEnabled, config.WriteTracing)
	c.Logger = s.Logger
	return c
}