12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- package dao
- import (
- "testing"
- )
- func TestUserDAOImpl_Save(t *testing.T) {
- userDAO := &UserDAOImpl{}
- err := InitMysql("127.0.0.1", "3306", "root", "123456", "user")
- if err != nil{
- t.Error(err)
- t.FailNow()
- }
- user := &UserEntity{
- Username:"aoho",
- Password:"aoho",
- Email:"aoho@mail.com",
- }
- err = userDAO.Save(user)
- if err != nil{
- t.Error(err)
- t.FailNow()
- }
- t.Logf("new User ID is %d", user.ID)
- }
- func TestUserDAOImpl_SelectByEmail(t *testing.T) {
- userDAO := &UserDAOImpl{}
- err := InitMysql("127.0.0.1", "3306", "root", "123456", "user")
- if err != nil{
- t.Error(err)
- t.FailNow()
- }
- user, err := userDAO.SelectByEmail("aoho@mail.com")
- if err != nil{
- t.Error(err)
- t.FailNow()
- }
- t.Logf("result uesrname is %s", user.Username)
- }
|