Exemple #1
0
func (s *Store) GetByEmail(email string) (*users.User, error) {
	u := new(users.User)
	u.Email = email
	has, e := s.eng.Get(u)
	if e != nil {
		return nil, e
	}
	if !has {
		return nil, users.ErrNotFound
	}
	return u, nil
}
Exemple #2
0
func (s *Store) GetByUserName(username string) (*users.User, error) {
	u := new(users.User)
	u.Name = username
	has, e := s.eng.Get(u)
	if e != nil {
		return nil, e
	}
	if !has {
		return nil, users.ErrNotFound
	}
	return u, nil
}
Exemple #3
0
func TestMem(t *testing.T) {
	Convey("testing mem", t, func() {
		s := new(Store)
		s.Driver = "sqlite3"
		e := s.Connect(":memory:")
		if e != nil {
			t.Error(e)
		}

		u := new(users.User)
		u.Name = "kirill"

		e = s.Save(u)
		if e != nil {
			t.Error(e)
		}

		l, e := s.eng.Count(&users.User{})
		if e != nil {
			t.Error(e)
		}
		So(l, ShouldEqual, 1)
	})
}