Ejemplo 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 {
	p, _ := getProvisioner()
	h := map[string]string{}
	for healer := range heal.All(p) {
		h[healer] = fmt.Sprintf("/healers/%s", healer)
	}
	return json.NewEncoder(w).Encode(h)
}
Ejemplo 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, nil)
	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{}
	p, _ := getProvisioner()
	for healer := range heal.All(p) {
		expected[healer] = fmt.Sprintf("/healers/%s", healer)
	}
	c.Assert(h, gocheck.DeepEquals, expected)
}