mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-09-15 18:57:01 +00:00
refactor: open boltdb only while using it (#1879)
* refactor: open boltdb only while using it * patch * Update handler_test.go * Update handler_test.go * Update handler_test.go * Update handler.go * timeout * 10 * pr feedback * fixup
This commit is contained in:
parent
19156ca8f6
commit
4d3a674f12
2 changed files with 83 additions and 42 deletions
|
@ -25,7 +25,10 @@ func TestHandler(t *testing.T) {
|
|||
|
||||
defer func() {
|
||||
t.Run("inpect db", func(t *testing.T) {
|
||||
require.NoError(t, handler.db.Bolt().View(func(tx *bbolt.Tx) error {
|
||||
db, err := handler.openDB()
|
||||
require.NoError(t, err)
|
||||
defer db.Close()
|
||||
require.NoError(t, db.Bolt().View(func(tx *bbolt.Tx) error {
|
||||
return tx.Bucket([]byte("Cache")).ForEach(func(k, v []byte) error {
|
||||
t.Logf("%s: %s", k, v)
|
||||
return nil
|
||||
|
@ -36,7 +39,6 @@ func TestHandler(t *testing.T) {
|
|||
require.NoError(t, handler.Close())
|
||||
assert.Nil(t, handler.server)
|
||||
assert.Nil(t, handler.listener)
|
||||
assert.Nil(t, handler.db)
|
||||
_, err := http.Post(fmt.Sprintf("%s/caches/%d", base, 1), "", nil)
|
||||
assert.Error(t, err)
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue