// TestRootRequest tests func TestRootRequest(t *testing.T) { assert := assert.New(t) var req RootRequest req = RootRequest{} req.needAccessToken = false assert.NoError(req.validate()) req.needAccessToken = true assert.Error(req.validate()) assert.Equal("", req.GetAccessToken()) token := accesstoken.Generate([]byte("foobar")) req.SetAccessToken(token.String()) assert.Equal(token.String(), req.GetAccessToken()) }
// CreateMe new user func (s MeService) CreateMe(name, avatarURL, location string) (*models.User, error) { token := accesstoken.Generate(accesstoken.GenerateRandomKey(32)) user := models.NewUser(name, avatarURL, location, token.String()) userRepository := models.NewUserRepository(s.ctx) return userRepository.Create(user) }