summaryrefslogtreecommitdiff
path: root/libpod/state_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'libpod/state_test.go')
-rw-r--r--libpod/state_test.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/libpod/state_test.go b/libpod/state_test.go
index b98674134..63e3bf173 100644
--- a/libpod/state_test.go
+++ b/libpod/state_test.go
@@ -26,9 +26,37 @@ var (
testedStates = map[string]emptyStateFunc{
"sql": getEmptySQLState,
"in-memory": getEmptyInMemoryState,
+ "boltdb": getEmptyBoltState,
}
)
+// Get an empty BoltDB state for use in tests
+func getEmptyBoltState() (s State, p string, p2 string, err error) {
+ tmpDir, err := ioutil.TempDir("", tmpDirPrefix)
+ if err != nil {
+ return nil, "", "", err
+ }
+ defer func() {
+ if err != nil {
+ os.RemoveAll(tmpDir)
+ }
+ }()
+
+ dbPath := filepath.Join(tmpDir, "db.sql")
+ lockDir := filepath.Join(tmpDir, "locks")
+
+ runtime := new(Runtime)
+ runtime.config = new(RuntimeConfig)
+ runtime.config.StorageConfig = storage.StoreOptions{}
+
+ state, err := NewBoltState(dbPath, lockDir, runtime)
+ if err != nil {
+ return nil, "", "", err
+ }
+
+ return state, tmpDir, lockDir, nil
+}
+
// Get an empty in-memory state for use in tests
func getEmptyInMemoryState() (s State, p string, p2 string, err error) {
tmpDir, err := ioutil.TempDir("", tmpDirPrefix)