(t *testing.T)
| 331 | } |
| 332 | |
| 333 | func TestBaseAppRefreshSettingsLoggerMinLevelEnabled(t *testing.T) { |
| 334 | scenarios := []struct { |
| 335 | name string |
| 336 | isDev bool |
| 337 | level int |
| 338 | // level->enabled map |
| 339 | expectations map[int]bool |
| 340 | }{ |
| 341 | { |
| 342 | "dev mode", |
| 343 | true, |
| 344 | 4, |
| 345 | map[int]bool{ |
| 346 | 3: true, |
| 347 | 4: true, |
| 348 | 5: true, |
| 349 | }, |
| 350 | }, |
| 351 | { |
| 352 | "nondev mode", |
| 353 | false, |
| 354 | 4, |
| 355 | map[int]bool{ |
| 356 | 3: false, |
| 357 | 4: true, |
| 358 | 5: true, |
| 359 | }, |
| 360 | }, |
| 361 | } |
| 362 | |
| 363 | for _, s := range scenarios { |
| 364 | t.Run(s.name, func(t *testing.T) { |
| 365 | const testDataDir = "./pb_base_app_test_data_dir/" |
| 366 | defer os.RemoveAll(testDataDir) |
| 367 | |
| 368 | app := core.NewBaseApp(core.BaseAppConfig{ |
| 369 | DataDir: testDataDir, |
| 370 | IsDev: s.isDev, |
| 371 | }) |
| 372 | defer app.ResetBootstrapState() |
| 373 | |
| 374 | if err := app.Bootstrap(); err != nil { |
| 375 | t.Fatal(err) |
| 376 | } |
| 377 | |
| 378 | // silence query logs |
| 379 | app.ConcurrentDB().(*dbx.DB).ExecLogFunc = func(ctx context.Context, t time.Duration, sql string, result sql.Result, err error) {} |
| 380 | app.ConcurrentDB().(*dbx.DB).QueryLogFunc = func(ctx context.Context, t time.Duration, sql string, rows *sql.Rows, err error) {} |
| 381 | app.NonconcurrentDB().(*dbx.DB).ExecLogFunc = func(ctx context.Context, t time.Duration, sql string, result sql.Result, err error) {} |
| 382 | app.NonconcurrentDB().(*dbx.DB).QueryLogFunc = func(ctx context.Context, t time.Duration, sql string, rows *sql.Rows, err error) {} |
| 383 | |
| 384 | handler, ok := app.Logger().Handler().(*logger.BatchHandler) |
| 385 | if !ok { |
| 386 | t.Fatalf("Expected BatchHandler, got %v", app.Logger().Handler()) |
| 387 | } |
| 388 | |
| 389 | app.Settings().Logs.MinLevel = s.level |
| 390 |
nothing calls this directly
no test coverage detected
searching dependent graphs…