From 2c8e60e1bb96c5723e5f9840c842d15474328dd4 Mon Sep 17 00:00:00 2001 From: lash Date: Tue, 21 Jan 2025 15:02:32 +0000 Subject: [PATCH] Add gdbmdb testutil --- testutil/fsdb.go | 8 ++++++-- testutil/gdbmdb.go | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 testutil/gdbmdb.go diff --git a/testutil/fsdb.go b/testutil/fsdb.go index 5c1368b..2f620b3 100644 --- a/testutil/fsdb.go +++ b/testutil/fsdb.go @@ -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) } diff --git a/testutil/gdbmdb.go b/testutil/gdbmdb.go new file mode 100644 index 0000000..908f5bf --- /dev/null +++ b/testutil/gdbmdb.go @@ -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 +}