(t *testing.T)
| 367 | } |
| 368 | |
| 369 | func 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, |
nothing calls this directly
no test coverage detected
searching dependent graphs…