golang-im聊天
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

user_dao_test.go 926 B

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package repo
  2. import (
  3. "fmt"
  4. "gim/internal/business/domain/user/model"
  5. "gim/pkg/db"
  6. "testing"
  7. )
  8. func init() {
  9. fmt.Println("init db")
  10. db.InitByTest()
  11. }
  12. func TestUserDao_Add(t *testing.T) {
  13. id, err := UserDao.Add(model.User{
  14. PhoneNumber: "18829291351",
  15. Nickname: "Alber",
  16. Sex: 1,
  17. AvatarUrl: "AvatarUrl",
  18. Extra: "Extra",
  19. })
  20. fmt.Printf("%+v\n %+v\n ", id, err)
  21. }
  22. func TestUserDao_Get(t *testing.T) {
  23. user, err := UserDao.Get(1)
  24. fmt.Printf("%+v\n %+v\n ", user, err)
  25. }
  26. func TestUserDao_GetByIds(t *testing.T) {
  27. users, err := UserDao.GetByIds([]int64{1, 2, 3})
  28. fmt.Printf("%+v\n %+v\n ", users, err)
  29. }
  30. func TestUserDao_GetByPhoneNumber(t *testing.T) {
  31. user, err := UserDao.GetByPhoneNumber("18829291351", 123456)
  32. fmt.Printf("%+v\n %+v\n ", user, err)
  33. }
  34. func TestUserDao_Search(t *testing.T) {
  35. users, err := UserDao.Search("18229", 123456)
  36. fmt.Printf("%+v\n %+v\n ", users, err)
  37. }