(t *testing.T)
| 191 | } |
| 192 | |
| 193 | func 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 | |
| 224 | func Test_userExampleHandler_List(t *testing.T) { |
| 225 | h := newUserExampleHandler() |
nothing calls this directly
no test coverage detected