| 8 | ) |
| 9 | |
| 10 | func TestIndex(t *testing.T) { |
| 11 | t.Run("Get", func(t *testing.T) { |
| 12 | // mockgen -source=user.go -destination=./mock/ |
| 13 | ctrl := gomock.NewController(t) |
| 14 | defer ctrl.Finish() |
| 15 | mockIndex := mock_user.NewMockIndex(ctrl) |
| 16 | mockIndex.EXPECT().Get("a").Return("haha") |
| 17 | res := mockIndex.Get("a") |
| 18 | assert.Equal(t, res, "haha") |
| 19 | }) |
| 20 | t.Run("GetTwo", func(t *testing.T) { |
| 21 | ctrl := gomock.NewController(t) |
| 22 | defer ctrl.Finish() |
| 23 | mockIndex := mock_user.NewMockIndex(ctrl) |
| 24 | mockIndex.EXPECT().GetTwo("", "").Return("res1", "res2") |
| 25 | res1, res2 := mockIndex.GetTwo("", "") |
| 26 | assert.Equal(t, res1, "res1") |
| 27 | assert.Equal(t, res2, "res2") |
| 28 | }) |
| 29 | } |