feat: lazysecrets list's JSON says when an entry was last used, and how often

This commit is contained in:
keb committed 2026-10-14 21:24:01 +02:00
1 parent 0e4580f245
commit 33a9b0864d
3 files changed
+23 -11

No files matched your search

+10 -2
View File
@@ -229,11 +229,14 @@ func TestListMarks(t *testing.T) {
az := fake.Azure(0)
var starredLink string
got, _, _ := run(t, Options{Providers: []provider.Provider{az}, MaxAge: time.Minute, Kinds: []string{"secret"},
Mark: func(link, account string) (bool, bool) {
Mark: func(link, account string) (bool, time.Time, int) {
if starredLink == "" && strings.HasSuffix(link, "/db-password") {
starredLink = link
}
return link == starredLink && account == az.ID(), strings.HasSuffix(link, "/api-key")
if strings.HasSuffix(link, "/api-key") {
return false, time.Now(), 3
}
return link == starredLink && account == az.ID(), time.Time{}, 0
}})
var starred, recent int
for _, e := range got {
@@ -245,6 +248,11 @@ func TestListMarks(t *testing.T) {
}
if e.Recent {
recent++
if e.Uses != 3 || e.LastUsed.IsZero() {
t.Errorf("%s: %d uses, last %v", e.Link, e.Uses, e.LastUsed)
}
} else if e.Uses != 0 || !e.LastUsed.IsZero() {
t.Errorf("%s not recent, but %d uses, last %v", e.Link, e.Uses, e.LastUsed)
}
}
if starred != 1 || recent == 0 {