SHARE
TWEET

Untitled

a guest Mar 25th, 2019 94 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. func TestMitraGetByPhoneNumber(t *testing.T) {
  2.     var mitraFieldNames = []string{"id", "phone", "email", "password"}
  3.     rows := sqlmock.NewRows(mitraFieldNames)
  4.     rows.AddRow("1", "0812345678", "abdul@gmail.com", "abcdefghi")
  5.     db, mock, _ := sqlmock.New()
  6.     gormDb, _ := gorm.Open("postgres", db)
  7.     gormDb.LogMode(true)
  8.     mock.ExpectQuery("^SELECT (.+) FROM \"mitras\".+$").WillReturnRows(rows)
  9.     models.SetDB(gormDb)
  10.     mitraRepo := new(MitraRepository)
  11.     mitra, _ := mitraRepo.GetByPhoneNumber("0812345678")
  12.     assert := assert.New(t)
  13.     assert.Equal("0812345678", mitra.Phone, "Username should be equal")
  14.     assert.Equal("abdul@gmail.com", mitra.Email, "Email should be equal")
  15.     assert.Equal("abcdefghi", mitra.Password, "Password should be equal")
  16. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top