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

Function Test_userExampleHandler_List

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

Source from the content-addressed store, hash-verified

222}
223
224func Test_userExampleHandler_List(t *testing.T) {
225 h := newUserExampleHandler()
226 defer h.Close()
227 testData := h.TestData.(*model.UserExample)
228
229 // column names and corresponding data
230 rows := sqlmock.NewRows([]string{"id"}).
231 AddRow(testData.ID)
232
233 h.MockDao.SQLMock.ExpectQuery("SELECT .*").WillReturnRows(rows)
234
235 result := &httpcli.StdResult{}
236 err := httpcli.Post(result, h.GetRequestURL("List"), &types.ListUserExamplesRequest{query.Params{
237 Page: 0,
238 Limit: 10,
239 Sort: "ignore count", // ignore test count
240 }})
241 if err != nil {
242 t.Fatal(err)
243 }
244 if result.Code != 0 {
245 t.Fatalf("%+v", result)
246 }
247
248 // nil params error test
249 err = httpcli.Post(result, h.GetRequestURL("List"), nil)
250 assert.NoError(t, err)
251
252 // get error test
253 err = httpcli.Post(result, h.GetRequestURL("List"), &types.ListUserExamplesRequest{query.Params{
254 Page: 0,
255 Limit: 10,
256 Sort: "unknown-column",
257 }})
258 assert.Error(t, err)
259}
260
261func TestNewUserExampleHandler(t *testing.T) {
262 defer func() {

Callers

nothing calls this directly

Calls 7

PostFunction · 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

Used in the wild real call sites across dependent graphs

searching dependent graphs…