Skip to content

Commit

Permalink
close the connection to bolt
Browse files Browse the repository at this point in the history
  • Loading branch information
deiu committed May 25, 2017
1 parent 871cddc commit c615cc1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
13 changes: 8 additions & 5 deletions pass_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func Test_Pass_Register(t *testing.T) {
err = ctx.registerPass(testUser, testPass)
assert.NoError(t, err)

boltCleanup(ctx.Config.BoltPath)
boltCleanup(ctx)
}

func Test_Pass_Verify(t *testing.T) {
Expand Down Expand Up @@ -57,7 +57,7 @@ func Test_Pass_Verify(t *testing.T) {
assert.NoError(t, err)
assert.True(t, ok)

boltCleanup(ctx.Config.BoltPath)
boltCleanup(ctx)
}

func Test_Pass_StoreNoUser(t *testing.T) {
Expand All @@ -72,11 +72,14 @@ func Test_Pass_StoreNoUser(t *testing.T) {

err = ctx.storePass("", testPass)
assert.Error(t, err)

boltCleanup(ctx)
}

func boltCleanup(path string) {
err := os.Remove(path)
func boltCleanup(ctx *Context) {
ctx.BoltDB.Close()
err := os.Remove(ctx.Config.BoltPath)
if err != nil {
panic("Failed to remove " + path)
panic("Failed to remove " + ctx.Config.BoltPath)
}
}
5 changes: 3 additions & 2 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ import (
"github.com/rs/zerolog"
)

const HelixVersion = "0.1"

var (
HELIX_VERSION = "0.1"
methodsAll = []string{
methodsAll = []string{
"OPTIONS", "HEAD", "GET", "POST", "PUT", "PATCH", "DELETE",
}
logger = zerolog.New(os.Stderr).With().Timestamp().Logger()
Expand Down
1 change: 1 addition & 0 deletions server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ func Test_StartBolt(t *testing.T) {
ctx.Config = NewConfig()
err = ctx.StartBolt()
assert.NoError(t, err)
defer ctx.BoltDB.Close()

err = os.Remove(ctx.Config.BoltPath)
assert.NoError(t, err)
Expand Down

0 comments on commit c615cc1

Please sign in to comment.