summaryrefslogtreecommitdiff
path: root/internal/store/data_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/store/data_test.go')
-rw-r--r--internal/store/data_test.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/internal/store/data_test.go b/internal/store/data_test.go
index 42721af..7bffd71 100644
--- a/internal/store/data_test.go
+++ b/internal/store/data_test.go
@@ -6,6 +6,7 @@ import (
"context"
"os"
"path/filepath"
+ "strings"
"testing"
"codeberg.org/snonux/foostore/internal/crypto"
@@ -240,3 +241,38 @@ func TestDataCommitSkipsExisting(t *testing.T) {
t.Errorf("file was overwritten: got %q; want %q", got, sentinel)
}
}
+
+func TestDataCommitMissingEncryptor(t *testing.T) {
+ ctx := context.Background()
+ dir := t.TempDir()
+ d := &Data{
+ Content: []byte("content"),
+ DataPath: filepath.Join(dir, "entry.data"),
+ }
+
+ err := d.Commit(ctx, nil, nil, true)
+ if err == nil {
+ t.Fatal("Commit with nil encryptor: expected error, got nil")
+ }
+ if !strings.Contains(err.Error(), "missing encryptor") {
+ t.Fatalf("Commit error = %q; want missing encryptor", err.Error())
+ }
+}
+
+func TestDataCommitMissingCommitter(t *testing.T) {
+ ctx := context.Background()
+ c := newTestCipher(t)
+ dir := t.TempDir()
+ d := &Data{
+ Content: []byte("content"),
+ DataPath: filepath.Join(dir, "entry.data"),
+ }
+
+ err := d.Commit(ctx, c, nil, true)
+ if err == nil {
+ t.Fatal("Commit with nil committer: expected error, got nil")
+ }
+ if !strings.Contains(err.Error(), "missing committer") {
+ t.Fatalf("Commit error = %q; want missing committer", err.Error())
+ }
+}