summaryrefslogtreecommitdiff
path: root/srv/src/mailinglist/store_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'srv/src/mailinglist/store_test.go')
-rw-r--r--srv/src/mailinglist/store_test.go23
1 files changed, 8 insertions, 15 deletions
diff --git a/srv/src/mailinglist/store_test.go b/srv/src/mailinglist/store_test.go
index 25eb150..9093d90 100644
--- a/srv/src/mailinglist/store_test.go
+++ b/srv/src/mailinglist/store_test.go
@@ -2,31 +2,24 @@ package mailinglist
import (
"io"
- "io/ioutil"
- "os"
"testing"
"time"
+ "github.com/mediocregopher/blog.mediocregopher.com/srv/cfg"
"github.com/stretchr/testify/assert"
)
func TestStore(t *testing.T) {
- tmpFile, err := ioutil.TempFile(os.TempDir(), "mediocre-blog-mailinglist-store-test-")
- if err != nil {
- t.Fatal("Cannot create temporary file", err)
- }
- tmpFilePath := tmpFile.Name()
- tmpFile.Close()
- t.Logf("using temporary sqlite file at %q", tmpFilePath)
+ var dataDir cfg.DataDir
- t.Cleanup(func() {
- if err := os.Remove(tmpFilePath); err != nil {
- panic(err)
- }
- })
+ if err := dataDir.Init(); err != nil {
+ t.Fatal(err)
+ }
+
+ t.Cleanup(func() { dataDir.Close() })
- store, err := NewStore(tmpFilePath)
+ store, err := NewStore(dataDir)
assert.NoError(t, err)
t.Cleanup(func() {