MCPcopy
hub / github.com/pocketbase/pocketbase / TestNewBaseAppTx

Function TestNewBaseAppTx

core/base_test.go:136–177  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

134}
135
136func TestNewBaseAppTx(t *testing.T) {
137 const testDataDir = "./pb_base_app_test_data_dir/"
138 defer os.RemoveAll(testDataDir)
139
140 app := core.NewBaseApp(core.BaseAppConfig{
141 DataDir: testDataDir,
142 })
143 defer app.ResetBootstrapState()
144
145 if err := app.Bootstrap(); err != nil {
146 t.Fatal(err)
147 }
148
149 mustNotHaveTx := func(app core.App) {
150 if app.IsTransactional() {
151 t.Fatalf("Didn't expect the app to be transactional")
152 }
153
154 if app.TxInfo() != nil {
155 t.Fatalf("Didn't expect the app.txInfo to be loaded")
156 }
157 }
158
159 mustHaveTx := func(app core.App) {
160 if !app.IsTransactional() {
161 t.Fatalf("Expected the app to be transactional")
162 }
163
164 if app.TxInfo() == nil {
165 t.Fatalf("Expected the app.txInfo to be loaded")
166 }
167 }
168
169 mustNotHaveTx(app)
170
171 app.RunInTransaction(func(txApp core.App) error {
172 mustHaveTx(txApp)
173 return nil
174 })
175
176 mustNotHaveTx(app)
177}
178
179func TestBaseAppNewMailClient(t *testing.T) {
180 const testDataDir = "./pb_base_app_test_data_dir/"

Callers

nothing calls this directly

Calls 7

ResetBootstrapStateMethod · 0.95
BootstrapMethod · 0.95
IsTransactionalMethod · 0.95
TxInfoMethod · 0.95
RunInTransactionMethod · 0.95
NewBaseAppFunction · 0.92
RemoveAllMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…