summaryrefslogtreecommitdiff
path: root/internal/authkeys/store_test.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-04-14 10:40:44 +0300
committerPaul Buetow <paul@buetow.org>2026-04-14 10:40:44 +0300
commitd49376f71dd8defebf80f901ecb60ab99f0f4906 (patch)
tree749322d2bf5c33d28ff95b77ebc674d69435c31c /internal/authkeys/store_test.go
parentff749457e392288e29dbf553bf8e0e64cc8b6401 (diff)
n3: validate SQLite with PingContext after Open
Call db.PingContext in storage.Open and authkeys.OpenStore; close DB and return wrapped errors on failure. Add tests for canceled context and invalid directory path. Made-with: Cursor
Diffstat (limited to 'internal/authkeys/store_test.go')
-rw-r--r--internal/authkeys/store_test.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/internal/authkeys/store_test.go b/internal/authkeys/store_test.go
index b8da623..797b683 100644
--- a/internal/authkeys/store_test.go
+++ b/internal/authkeys/store_test.go
@@ -2,11 +2,25 @@ package authkeys
import (
"context"
+ "errors"
"path/filepath"
"strings"
"testing"
)
+func TestOpenStore_ContextCanceled(t *testing.T) {
+ ctx, cancel := context.WithCancel(context.Background())
+ cancel()
+ path := filepath.Join(t.TempDir(), "auth.db")
+ _, err := OpenStore(ctx, path)
+ if err == nil {
+ t.Fatal("expected error")
+ }
+ if !errors.Is(err, context.Canceled) {
+ t.Fatalf("expected context.Canceled, got %v", err)
+ }
+}
+
func TestCreateVerifyReplace(t *testing.T) {
ctx := context.Background()
path := filepath.Join(t.TempDir(), "auth.db")