summaryrefslogtreecommitdiff
path: root/internal/cli/kdbx_store_test.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-04-17 08:45:18 +0300
committerPaul Buetow <paul@buetow.org>2026-04-17 08:45:18 +0300
commiteb89e32c6675d4ed50f66580346e5ea8f3d7b5b2 (patch)
tree916d5299642622d3344778222e88db16aeace1ae /internal/cli/kdbx_store_test.go
parent9e2bf4af8b7b3b4ca2980aa6285482e7db0cd151 (diff)
refactor: deduplicate cli/kdbx_store.go using exported keepass helpers (tasks k4+l4)
Remove ~90 lines of duplicated code from kdbx_store.go by delegating to EnsureGroup, UpsertEntryByTitle, SetEntryField, SplitDescriptionPath, SanitizeRelativePath exported from internal/keepass. kdbxStore.Save() now delegates to keepass.AtomicSave, eliminating the double-close risk. migrate_kdbx.go updated to use the exported helpers. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/cli/kdbx_store_test.go')
-rw-r--r--internal/cli/kdbx_store_test.go14
1 files changed, 9 insertions, 5 deletions
diff --git a/internal/cli/kdbx_store_test.go b/internal/cli/kdbx_store_test.go
index fc79ca6..bff1a0a 100644
--- a/internal/cli/kdbx_store_test.go
+++ b/internal/cli/kdbx_store_test.go
@@ -1,11 +1,15 @@
package cli
-import "testing"
+import (
+ "testing"
+
+ "codeberg.org/snonux/foostore/internal/keepass"
+)
func TestSplitDescriptionPath(t *testing.T) {
- group, title, err := splitDescriptionPath("foo/bar/baz")
+ group, title, err := keepass.SplitDescriptionPath("foo/bar/baz")
if err != nil {
- t.Fatalf("splitDescriptionPath: %v", err)
+ t.Fatalf("SplitDescriptionPath: %v", err)
}
if title != "baz" {
t.Fatalf("title = %q; want baz", title)
@@ -16,8 +20,8 @@ func TestSplitDescriptionPath(t *testing.T) {
}
func TestSanitizeRelativePathRejectsTraversal(t *testing.T) {
- if _, err := sanitizeRelativePath("../secret"); err == nil {
- t.Fatal("sanitizeRelativePath should reject traversal path")
+ if _, err := keepass.SanitizeRelativePath("../secret"); err == nil {
+ t.Fatal("SanitizeRelativePath should reject traversal path")
}
}