blob: 51198c86ea63db53f2c5a15335ed6f5202f58701 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
package main_test
import (
"io/ioutil"
"os"
"strings"
"github.com/boltdb/bolt"
. "github.com/boltdb/bolt/cmd/bolt"
)
// 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())
db, err := bolt.Open(f.Name(), 0600)
if err != nil {
panic("db open error: " + err.Error())
}
fn(db)
}
// run executes a command against the CLI and returns the output.
func run(args ...string) string {
args = append([]string{"bolt"}, args...)
NewApp().Run(args)
return strings.TrimSpace(LogBuffer())
}
|