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

Function TestNewManager_InternalApplicationManagement

plugin/manager_test.go:369–445  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

367}
368
369func TestNewManager_InternalApplicationManagement(t *testing.T) {
370 db := testdb.NewDBWithDefaultUser(t)
371
372 {
373 // Application exist, no plugin conf
374 db.CreateApplication(&model.Application{
375 Token: "Ainternal_obsolete",
376 Internal: true,
377 Name: "obsolete plugin application",
378 UserID: 1,
379 })
380
381 if app, err := db.GetApplicationByToken("Ainternal_obsolete"); assert.NoError(t, err) {
382 assert.True(t, app.Internal)
383 }
384 _, err := NewManager(db, "", nil, nil)
385 assert.Nil(t, err)
386 if app, err := db.GetApplicationByToken("Ainternal_obsolete"); assert.NoError(t, err) {
387 assert.False(t, app.Internal)
388 }
389 }
390 {
391 // Application exist, conf exist, no compat
392 assert.NoError(t, db.CreateApplication(&model.Application{
393 Token: "Ainternal_not_loaded",
394 Internal: true,
395 Name: "not loaded plugin application",
396 UserID: 1,
397 }))
398 if app, err := db.GetApplicationByToken("Ainternal_not_loaded"); assert.NoError(t, err) {
399 assert.NoError(t, db.CreatePluginConf(&model.PluginConf{
400 ApplicationID: app.ID,
401 UserID: 1,
402 Enabled: true,
403 Token: auth.GeneratePluginToken(),
404 }))
405 }
406
407 if app, err := db.GetApplicationByToken("Ainternal_not_loaded"); assert.NoError(t, err) {
408 assert.True(t, app.Internal)
409 }
410 _, err := NewManager(db, "", nil, nil)
411 assert.Nil(t, err)
412 if app, err := db.GetApplicationByToken("Ainternal_not_loaded"); assert.NoError(t, err) {
413 assert.False(t, app.Internal)
414 }
415 }
416 {
417 // Application exist, conf exist, has compat
418 assert.NoError(t, db.CreateApplication(&model.Application{
419 Token: "Ainternal_loaded",
420 Internal: false,
421 Name: "not loaded plugin application",
422 UserID: 1,
423 }))
424 if app, err := db.GetApplicationByToken("Ainternal_loaded"); assert.NoError(t, err) {
425 assert.NoError(t, db.CreatePluginConf(&model.PluginConf{
426 ApplicationID: app.ID,

Callers

nothing calls this directly

Calls 8

LoadPluginMethod · 0.95
InitializeForUserIDMethod · 0.95
NewDBWithDefaultUserFunction · 0.92
GeneratePluginTokenFunction · 0.92
NewManagerFunction · 0.85
CreateApplicationMethod · 0.65
GetApplicationByTokenMethod · 0.65
CreatePluginConfMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…