Add gdbmdb testutil

This commit is contained in:
lash 2025-01-21 15:02:32 +00:00
parent 4baacb325d
commit 2c8e60e1bb
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
2 changed files with 39 additions and 2 deletions

View File

@ -7,13 +7,17 @@ import (
)
const (
testDbCookie = true
)
func init() {
stateDir, err := os.MkdirTemp("", "sarafu-vise-menutraversal-state-")
stateDir, err := os.MkdirTemp("", "sarafu-vise-menutraversal-fs-state-")
if err != nil {
panic(err)
}
override.StateConn = &stateDir
userDir, err := os.MkdirTemp("", "sarafu-vise-menutraversal-user-")
userDir, err := os.MkdirTemp("", "sarafu-vise-menutraversal-fs-user-")
if err != nil {
panic(err)
}

33
testutil/gdbmdb.go Normal file
View File

@ -0,0 +1,33 @@
// +build testgdbmdb
package testutil
import (
"os"
"net/url"
)
const (
testDbCookie = true
)
func init() {
stateDir, err := os.MkdirTemp("", "sarafu-vise-menutraversal-gdbm-state-")
if err != nil {
panic(err)
}
stateDir, err = url.JoinPath("gdbm:///", stateDir)
if err != nil {
panic(err)
}
override.StateConn = &stateDir
userDir, err := os.MkdirTemp("", "sarafu-vise-menutraversal-gdbm-user-")
if err != nil {
panic(err)
}
userDir, err = url.JoinPath("gdbm:///", userDir)
if err != nil {
panic(err)
}
override.UserConn = &userDir
}