mirror of
https://gitea.com/gitea/runner.git
synced 2026-11-06 23:30:29 +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:
1 parent
310cb79e81
commit
e597046195
2 files changed
+83
-42
No files matched your search
@@ -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)
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user