diff options
author | Ben Johnson <benbjohnson@yahoo.com> | 2014-04-11 14:31:34 -0600 |
---|---|---|
committer | Ben Johnson <benbjohnson@yahoo.com> | 2014-04-11 14:31:34 -0600 |
commit | 714436100adf98a5132e6f4ddb3290231ff89dfd (patch) | |
tree | 8a9272322aa759b3d911d3698e6ec21cf71e78d7 /cmd/bolt/main_test.go | |
parent | Add nested buckets. (diff) | |
parent | Merge pull request #128 from benbjohnson/import-export (diff) | |
download | dedo-714436100adf98a5132e6f4ddb3290231ff89dfd.tar.gz dedo-714436100adf98a5132e6f4ddb3290231ff89dfd.tar.xz |
Merge branch 'master' into nested-keys
Conflicts:
db_test.go
tx_test.go
Diffstat (limited to 'cmd/bolt/main_test.go')
-rw-r--r-- | cmd/bolt/main_test.go | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/cmd/bolt/main_test.go b/cmd/bolt/main_test.go index 51198c8..9b32cc8 100644 --- a/cmd/bolt/main_test.go +++ b/cmd/bolt/main_test.go @@ -10,17 +10,15 @@ import ( ) // open creates and opens a Bolt database in the temp directory. -func open(fn func(*bolt.DB)) { - f, _ := ioutil.TempFile("", "bolt-") - f.Close() - os.Remove(f.Name()) - defer os.RemoveAll(f.Name()) +func open(fn func(*bolt.DB, string)) { + path := tempfile() + defer os.RemoveAll(path) - db, err := bolt.Open(f.Name(), 0600) + db, err := bolt.Open(path, 0600) if err != nil { panic("db open error: " + err.Error()) } - fn(db) + fn(db, path) } // run executes a command against the CLI and returns the output. @@ -29,3 +27,11 @@ func run(args ...string) string { NewApp().Run(args) return strings.TrimSpace(LogBuffer()) } + +// tempfile returns a temporary file path. +func tempfile() string { + f, _ := ioutil.TempFile("", "bolt-") + f.Close() + os.Remove(f.Name()) + return f.Name() +} |