MCPcopy
hub / github.com/gotify/server / Test_Sorting

Method Test_Sorting

api/application_test.go:211–249  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

209}
210
211func (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
251func (s *ApplicationSuite) Test_GetApplications() {
252 userBuilder := s.db.User(5)

Callers

nothing calls this directly

Calls 6

withFormDataMethod · 0.95
WithUserFunction · 0.92
UserMethod · 0.80
CreateApplicationMethod · 0.65
GetApplicationsByUserMethod · 0.65
UpdateApplicationMethod · 0.65

Tested by

no test coverage detected