MCPcopy Index your code
hub / github.com/go-dev-frame/sponge / Test_userExampleHandler_GetByID

Function Test_userExampleHandler_GetByID

internal/handler/userExample_test.go:193–222  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

191}
192
193func Test_userExampleHandler_GetByID(t *testing.T) {
194 h := newUserExampleHandler()
195 defer h.Close()
196 testData := h.TestData.(*model.UserExample)
197
198 // column names and corresponding data
199 rows := sqlmock.NewRows([]string{"id"}).
200 AddRow(testData.ID)
201
202 h.MockDao.SQLMock.ExpectQuery("SELECT .*").
203 WithArgs(testData.ID, 1).
204 WillReturnRows(rows)
205
206 result := &httpcli.StdResult{}
207 err := httpcli.Get(result, h.GetRequestURL("GetByID", testData.ID))
208 if err != nil {
209 t.Fatal(err)
210 }
211 if result.Code != 0 {
212 t.Fatalf("%+v", result)
213 }
214
215 // zero id error test
216 err = httpcli.Get(result, h.GetRequestURL("GetByID", 0))
217 assert.NoError(t, err)
218
219 // get error test
220 err = httpcli.Get(result, h.GetRequestURL("GetByID", 111))
221 assert.Error(t, err)
222}
223
224func Test_userExampleHandler_List(t *testing.T) {
225 h := newUserExampleHandler()

Callers

nothing calls this directly

Calls 7

GetFunction · 0.92
newUserExampleHandlerFunction · 0.85
GetRequestURLMethod · 0.80
FatalfMethod · 0.80
CloseMethod · 0.65
ErrorMethod · 0.65
FatalMethod · 0.45

Tested by

no test coverage detected