()
| 209 | } |
| 210 | |
| 211 | func (s *ApplicationSuite) Test_Sorting() { |
| 212 | s.db.User(5) |
| 213 | |
| 214 | test.WithUser(s.ctx, 5) |
| 215 | s.withFormData("name=one") |
| 216 | s.a.CreateApplication(s.ctx) |
| 217 | |
| 218 | test.WithUser(s.ctx, 5) |
| 219 | s.withFormData("name=two") |
| 220 | s.a.CreateApplication(s.ctx) |
| 221 | |
| 222 | test.WithUser(s.ctx, 5) |
| 223 | s.withFormData("name=three") |
| 224 | s.a.CreateApplication(s.ctx) |
| 225 | |
| 226 | apps, err := s.db.GetApplicationsByUser(5) |
| 227 | require.NoError(s.T(), err) |
| 228 | require.Len(s.T(), apps, 3) |
| 229 | assert.Equal(s.T(), apps[0].Name, "one") |
| 230 | assert.Equal(s.T(), apps[0].SortKey, "a0") |
| 231 | assert.Equal(s.T(), apps[1].Name, "two") |
| 232 | assert.Equal(s.T(), apps[1].SortKey, "a1") |
| 233 | assert.Equal(s.T(), apps[2].Name, "three") |
| 234 | assert.Equal(s.T(), apps[2].SortKey, "a2") |
| 235 | |
| 236 | s.withFormData("name=one&description=&sortKey=a1V") |
| 237 | s.ctx.Params = gin.Params{{Key: "id", Value: fmt.Sprint(apps[0].ID)}} |
| 238 | s.a.UpdateApplication(s.ctx) |
| 239 | |
| 240 | apps, err = s.db.GetApplicationsByUser(5) |
| 241 | require.NoError(s.T(), err) |
| 242 | require.Len(s.T(), apps, 3) |
| 243 | assert.Equal(s.T(), apps[0].Name, "two") |
| 244 | assert.Equal(s.T(), apps[0].SortKey, "a1") |
| 245 | assert.Equal(s.T(), apps[1].Name, "one") |
| 246 | assert.Equal(s.T(), apps[1].SortKey, "a1V") |
| 247 | assert.Equal(s.T(), apps[2].Name, "three") |
| 248 | assert.Equal(s.T(), apps[2].SortKey, "a2") |
| 249 | } |
| 250 | |
| 251 | func (s *ApplicationSuite) Test_GetApplications() { |
| 252 | userBuilder := s.db.User(5) |
nothing calls this directly
no test coverage detected