summaryrefslogtreecommitdiffstats
path: root/db
diff options
context:
space:
mode:
authorsiddharth ravikumar <s@ricketyspace.net>2022-12-25 11:58:47 -0500
committersiddharth ravikumar <s@ricketyspace.net>2022-12-25 11:58:47 -0500
commitb64cce52d9011d9c85bc68041e998f2a0c513867 (patch)
tree1b6bdccc39e06579f9471497d8ae0ce291b5687f /db
parent28386eb5f6c57b724c203b6043b211db36fc6c41 (diff)
db: add `defaultDBPath`
For storing the default db path. The `dbPath` gets changed during tests. The `defaultDBPath` can be used to reset `dbPath` back to the default db path through the `resetDBPath` function.
Diffstat (limited to 'db')
-rw-r--r--db/db.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/db/db.go b/db/db.go
index d935467..c13f6d1 100644
--- a/db/db.go
+++ b/db/db.go
@@ -14,6 +14,7 @@ import (
)
var dbPath string
+var defaultDBPath string
// Contains information about list of media that where already
// download for different feeds.
@@ -34,8 +35,8 @@ func init() {
if err != nil {
return
}
- dbPath = path.Join(h, ".config", "fern", "db.json")
-
+ defaultDBPath = path.Join(h, ".config", "fern", "db.json")
+ dbPath = defaultDBPath
}
// Reads the fern db from disk and unmarshals it into a FernDB
@@ -140,3 +141,9 @@ func (fdb *FernDB) Write() error {
}
return nil
}
+
+// Sets DB path to the default path. This function is meant to be used
+// by tests.
+func resetDBPath() {
+ dbPath = defaultDBPath
+}