Exemplo n.º 1
0
// healers returns a json with all healers registered and yours endpoints.
func healers(w http.ResponseWriter, r *http.Request, t *auth.Token) error {
	h := map[string]string{}
	for healer := range heal.All() {
		h[healer] = fmt.Sprintf("/healers/%s", healer)
	}
	return json.NewEncoder(w).Encode(h)
}
Exemplo n.º 2
0
func (s *HealerSuite) TestHealers(c *gocheck.C) {
	recorder := httptest.NewRecorder()
	request, err := http.NewRequest("GET", "/healers", nil)
	c.Assert(err, gocheck.IsNil)
	err = healers(recorder, request)
	c.Assert(err, gocheck.IsNil)
	c.Assert(recorder.Code, gocheck.Equals, http.StatusOK)
	body, err := ioutil.ReadAll(recorder.Body)
	c.Assert(err, gocheck.IsNil)
	h := map[string]string{}
	err = json.Unmarshal(body, &h)
	c.Assert(err, gocheck.IsNil)
	expected := map[string]string{}
	for healer := range heal.All() {
		expected[healer] = fmt.Sprintf("/healers/%s", healer)
	}
	c.Assert(h, gocheck.DeepEquals, expected)
}