package ledger import ( "context" "testing" "github.com/carlosframework/platform/internal/release" ) func TestPutBlobIdempotent(t *testing.T) { st := release.NewDirStore(t.TempDir()) ctx := context.Background() body := []byte("redacted corpus bytes") sha1, err := PutBlob(ctx, st, "bab", "platform", "prompts", body) if err != nil { t.Fatal(err) } sha2, err := PutBlob(ctx, st, "bab", "platform", "prompts", body) if err != nil { t.Fatalf("re-upload of identical content errored: %v", err) } if sha1 != sha2 || sha1 != SHA256Hex(body) { t.Fatalf("sha mismatch: %s %s", sha1, sha2) } got, _, err := st.Get(ctx, BlobKey("bab", "platform", "prompts", sha1)) if err != nil || string(got) != string(body) { t.Fatalf("stored blob: %q %v", got, err) } } func TestPutBlobRejectsOversize(t *testing.T) { st := release.NewDirStore(t.TempDir()) if _, err := PutBlob(context.Background(), st, "bab", "platform", "prompts", make([]byte, MaxBlob+1)); err == nil { t.Fatal("oversized blob accepted") } }