diff --git a/store/bolt.go b/store/bolt.go index 700469c..7d81758 100644 --- a/store/bolt.go +++ b/store/bolt.go @@ -18,6 +18,10 @@ func NewBolt(path string) (*BoltClient, error) { }, nil } +func (bc *BoltClient) Close() error { + return bc.db.Close() +} + func (bc *BoltClient) Set(namespace, key string, value []byte) error { return bc.db.Update(func(tx *bolt.Tx) error { bucket, err := tx.CreateBucketIfNotExists([]byte(namespace)) diff --git a/store/bolt_test.go b/store/bolt_test.go index c6f9011..4bb1086 100644 --- a/store/bolt_test.go +++ b/store/bolt_test.go @@ -45,6 +45,7 @@ func Test_BoltSetListGet(t *testing.T) { defer os.Remove(tmp.Name()) var sc Client sc, err = NewBolt(tmp.Name()) + defer sc.Close() if err != nil { t.Errorf("failed to create bolt %v: %v", sc, err) } diff --git a/store/store.go b/store/store.go index 6d9cc83..3150ef7 100644 --- a/store/store.go +++ b/store/store.go @@ -4,4 +4,5 @@ type Client interface { Get(string, string) ([]byte, error) Set(string, string, []byte) error List(string, string) ([]string, error) + Close() error }