(t *testing.T)
| 222 | } |
| 223 | |
| 224 | func 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 | |
| 261 | func TestNewUserExampleHandler(t *testing.T) { |
| 262 | defer func() { |
nothing calls this directly
no test coverage detected
searching dependent graphs…