summaryrefslogtreecommitdiff
path: root/libpod/state_test.go
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@gmail.com>2017-12-13 22:02:15 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2018-02-12 14:28:07 +0000
commitb4cdc27b31a638322fb83b64aea869ce8600ea01 (patch)
tree5d248aeafa1f54a2c169d1d51deaaeb5de1e0e23 /libpod/state_test.go
parent2e96acf3007cbd05a37a8af7156f0abda073cb5a (diff)
downloadpodman-b4cdc27b31a638322fb83b64aea869ce8600ea01.tar.gz
podman-b4cdc27b31a638322fb83b64aea869ce8600ea01.tar.bz2
podman-b4cdc27b31a638322fb83b64aea869ce8600ea01.zip
Add implementation for BoltDB-backed state
Signed-off-by: Matthew Heon <matthew.heon@gmail.com> Closes: #184 Approved by: baude
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)