(t *testing.T)
| 58 | } |
| 59 | |
| 60 | func TestBaseAppBootstrap(t *testing.T) { |
| 61 | const testDataDir = "./pb_base_app_test_data_dir/" |
| 62 | defer os.RemoveAll(testDataDir) |
| 63 | |
| 64 | app := core.NewBaseApp(core.BaseAppConfig{ |
| 65 | DataDir: testDataDir, |
| 66 | }) |
| 67 | defer app.ResetBootstrapState() |
| 68 | |
| 69 | if app.IsBootstrapped() { |
| 70 | t.Fatal("Didn't expect the application to be bootstrapped.") |
| 71 | } |
| 72 | |
| 73 | if err := app.Bootstrap(); err != nil { |
| 74 | t.Fatal(err) |
| 75 | } |
| 76 | |
| 77 | if !app.IsBootstrapped() { |
| 78 | t.Fatal("Expected the application to be bootstrapped.") |
| 79 | } |
| 80 | |
| 81 | if stat, err := os.Stat(testDataDir); err != nil || !stat.IsDir() { |
| 82 | t.Fatal("Expected test data directory to be created.") |
| 83 | } |
| 84 | |
| 85 | type nilCheck struct { |
| 86 | name string |
| 87 | value any |
| 88 | expectNil bool |
| 89 | } |
| 90 | |
| 91 | runNilChecks := func(checks []nilCheck) { |
| 92 | for _, check := range checks { |
| 93 | t.Run(check.name, func(t *testing.T) { |
| 94 | isNil := check.value == nil |
| 95 | if isNil != check.expectNil { |
| 96 | t.Fatalf("Expected isNil %v, got %v", check.expectNil, isNil) |
| 97 | } |
| 98 | }) |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | nilChecksBeforeReset := []nilCheck{ |
| 103 | {"[before] db", app.DB(), false}, |
| 104 | {"[before] concurrentDB", app.ConcurrentDB(), false}, |
| 105 | {"[before] nonconcurrentDB", app.NonconcurrentDB(), false}, |
| 106 | {"[before] auxDB", app.AuxDB(), false}, |
| 107 | {"[before] auxConcurrentDB", app.AuxConcurrentDB(), false}, |
| 108 | {"[before] auxNonconcurrentDB", app.AuxNonconcurrentDB(), false}, |
| 109 | {"[before] settings", app.Settings(), false}, |
| 110 | {"[before] logger", app.Logger(), false}, |
| 111 | {"[before] cached collections", app.Store().Get(core.StoreKeyCachedCollections), false}, |
| 112 | } |
| 113 | |
| 114 | runNilChecks(nilChecksBeforeReset) |
| 115 | |
| 116 | // reset |
| 117 | if err := app.ResetBootstrapState(); err != nil { |
nothing calls this directly
no test coverage detected
searching dependent graphs…