Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
efectn committed Sep 15, 2023
1 parent 09e12a7 commit e6700b3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 28 deletions.
16 changes: 3 additions & 13 deletions arangodb/arangodb_test.go
Original file line number Diff line number Diff line change
@@ -1,25 +1,15 @@
package arangodb

import (
"os"
"testing"
"time"

"github.com/stretchr/testify/require"
)

var testStore *Storage

func TestMain(m *testing.M) {
testStore = New(Config{
Reset: true,
})

code := m.Run()

_ = testStore.Close()
os.Exit(code)
}
var testStore = New(Config{
Reset: true,
})

func Test_ArangoDB_Set(t *testing.T) {
var (
Expand Down
16 changes: 3 additions & 13 deletions badger/badger_test.go
Original file line number Diff line number Diff line change
@@ -1,25 +1,15 @@
package badger

import (
"os"
"testing"
"time"

"github.com/stretchr/testify/require"
)

var testStore *Storage

func TestMain(m *testing.M) {
testStore = New(Config{
Reset: true,
})

code := m.Run()

_ = testStore.Close()
os.Exit(code)
}
var testStore = New(Config{
Reset: true,
})

func Test_Badger_Set(t *testing.T) {
var (
Expand Down
3 changes: 2 additions & 1 deletion bbolt/bbolt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ var testStore *Storage

func TestMain(m *testing.M) {
testStore = New(Config{
Reset: true,
Bucket: "fiber-bucket",
Reset: true,
})

code := m.Run()
Expand Down
8 changes: 7 additions & 1 deletion bbolt/utils.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package bbolt

import (
"errors"
"github.com/gofiber/utils/v2"
"go.etcd.io/bbolt"
)
Expand All @@ -15,6 +16,11 @@ func createBucket(cfg Config, conn *bbolt.DB) error {

func removeBucket(cfg Config, conn *bbolt.DB) error {
return conn.Update(func(tx *bbolt.Tx) error {
return tx.DeleteBucket(utils.UnsafeBytes(cfg.Bucket))
err := tx.DeleteBucket(utils.UnsafeBytes(cfg.Bucket))
if errors.Is(err, bbolt.ErrBucketNotFound) {
return nil
}

return err
})
}

0 comments on commit e6700b3

Please sign in to comment.