Example #1
0
func (s *S) TestSetAndGetCurrentUser(c *C) {
	user := &account.User{Name: "Alice", Email: "*****@*****.**", Password: "******"}
	req, _ := http.NewRequest("GET", "/foo", nil)
	api.SetCurrentUser(req, user)
	u, err := api.GetCurrentUser(req)
	c.Assert(u, DeepEquals, user)
	c.Check(err, IsNil)
}
Example #2
0
func (s *S) TestGetCurrentUserNotSignedIn(c *C) {
	req, _ := http.NewRequest("GET", "/foo", nil)
	u, err := api.GetCurrentUser(req)
	c.Check(u, IsNil)
	c.Assert(err, Equals, errors.ErrLoginRequired)
}