lockbox

password manager
Log | Files | Refs | README | LICENSE

commit f5555afa2fce2cff522e2246008e3971fa4ba006
parent 82a98ca72471b556c42147bb04cb93b7e5e2fe44
Author: Sean Enck <sean@ttypty.com>
Date:   Sun,  2 Oct 2022 13:38:03 -0400

cleaning up and allow a smaller root

Diffstat:
Minternal/backend/actions.go | 6+++---
Minternal/backend/actions_test.go | 6+++---
Minternal/backend/query_test.go | 2+-
Minternal/backend/types.go | 4++--
4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/internal/backend/actions.go b/internal/backend/actions.go @@ -151,11 +151,11 @@ func findAndDo(isAdd bool, entityName string, offset []string, opEntity *gokeepa } func splitComponents(path string) ([]string, string, error) { - title := filepath.Base(path) - parts := strings.Split(filepath.Dir(path), pathSep) - if len(parts) < 2 { + if len(strings.Split(path, pathSep)) < 2 { return nil, "", errPath } + title := filepath.Base(path) + parts := strings.Split(filepath.Dir(path), pathSep) return parts, title, nil } diff --git a/internal/backend/actions_test.go b/internal/backend/actions_test.go @@ -74,10 +74,10 @@ func TestInserts(t *testing.T) { if err := setup(t).Insert("", ""); err.Error() != "empty path not allowed" { t.Errorf("wrong error: %v", err) } - if err := setup(t).Insert(filepath.Join("test", "offset"), "test"); err.Error() != "input paths must contain at LEAST 3 components (e.g. abc/123/xyz)" { + if err := setup(t).Insert("tests", "test"); err.Error() != "input paths must contain at LEAST 2 components" { t.Errorf("wrong error: %v", err) } - if err := setup(t).Insert("test", "test"); err.Error() != "input paths must contain at LEAST 3 components (e.g. abc/123/xyz)" { + if err := setup(t).Insert("test", "test"); err.Error() != "input paths must contain at LEAST 2 components" { t.Errorf("wrong error: %v", err) } if err := setup(t).Insert("a", ""); err.Error() != "empty secret not allowed" { @@ -115,7 +115,7 @@ func TestRemoves(t *testing.T) { if err := setup(t).Remove(nil); err.Error() != "entity is empty/invalid" { t.Errorf("wrong error: %v", err) } - if err := setup(t).Remove(&backend.QueryEntity{}); err.Error() != "input paths must contain at LEAST 3 components (e.g. abc/123/xyz)" { + if err := setup(t).Remove(&backend.QueryEntity{}); err.Error() != "input paths must contain at LEAST 2 components" { t.Errorf("wrong error: %v", err) } if err := setup(t).Remove(&backend.QueryEntity{Path: filepath.Join("test1", "test2", "test3")}); err.Error() != "failed to remove entity" { diff --git a/internal/backend/query_test.go b/internal/backend/query_test.go @@ -28,7 +28,7 @@ func TestGet(t *testing.T) { if err != nil || q != nil { t.Error("invalid result, should be empty") } - if _, err := fullSetup(t, true).Get("aaaa", backend.BlankValue); err.Error() != "input paths must contain at LEAST 3 components (e.g. abc/123/xyz)" { + if _, err := fullSetup(t, true).Get("aaaa", backend.BlankValue); err.Error() != "input paths must contain at LEAST 2 components" { t.Errorf("invalid error: %v", err) } } diff --git a/internal/backend/types.go b/internal/backend/types.go @@ -2,7 +2,7 @@ package backend import ( - "fmt" + "errors" "os" "github.com/tobischo/gokeepasslib/v3" @@ -69,5 +69,5 @@ const ( ) var ( - errPath = fmt.Errorf("input paths must contain at LEAST 3 components (e.g. abc%c123%cxyz)", os.PathSeparator, os.PathSeparator) + errPath = errors.New("input paths must contain at LEAST 2 components") )