MCPcopy
hub / github.com/betty200744/ultimate-go / TestIndex

Function TestIndex

mock/user/user_test.go:10–29  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func 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}

Callers

nothing calls this directly

Calls 6

EXPECTMethod · 0.95
GetMethod · 0.95
GetTwoMethod · 0.95
GetMethod · 0.65
GetTwoMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected