summaryrefslogtreecommitdiffstats
path: root/db
diff options
context:
space:
mode:
authorsiddharth <s@ricketyspace.net>2021-11-28 17:15:39 -0500
committersiddharth <s@ricketyspace.net>2021-11-28 17:15:39 -0500
commit43dade27aa1cd5e77201c3100276f299e321d213 (patch)
treece74ffecc8448179e3d7fd9a554d73304c724daa /db
parent337741015cc46179fa8886079a416bb2fe4f4845 (diff)
db: update TestOpenExistingDB
Refactor dbFile closing.
Diffstat (limited to 'db')
-rw-r--r--db/db_test.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/db/db_test.go b/db/db_test.go
index e2308c1..37ec6ca 100644
--- a/db/db_test.go
+++ b/db/db_test.go
@@ -69,14 +69,16 @@ func TestOpenExistingDB(t *testing.T) {
// Write a sample test db to fern-db.json
testDBJSON := []byte(`{"mkbhd":["rivian","v-raptor","m1-imac"],"npr":["william-prince","joy-oladokun","lucy-ducas"],"simone":["weightless","ugly-desks","safety-hat"]}`)
dbFile, err := os.Create(dbPath)
+ defer dbFile.Close()
if err != nil {
t.Errorf("Unable to create fern-db.json: %v", err.Error())
+ return
}
n, err := dbFile.Write(testDBJSON)
if len(testDBJSON) != n {
t.Errorf("Write to fern-db.json failed: %v", err.Error())
+ return
}
- dbFile.Close()
// Open the db.
db, err := Open()