carlos / platform Public

Clone
git clone https://amadan.net/carlos/platform

Plain git — no account needed to clone.

Download

Download this file

1package ledger
2
3import (
4 "context"
5 "testing"
6
7 "github.com/carlosframework/platform/internal/release"
8)
9
10func TestPutBlobIdempotent(t *testing.T) {
11 st := release.NewDirStore(t.TempDir())
12 ctx := context.Background()
13 body := []byte("redacted corpus bytes")
14 sha1, err := PutBlob(ctx, st, "bab", "platform", "prompts", body)
15 if err != nil {
16 t.Fatal(err)
17 }
18 sha2, err := PutBlob(ctx, st, "bab", "platform", "prompts", body)
19 if err != nil {
20 t.Fatalf("re-upload of identical content errored: %v", err)
21 }
22 if sha1 != sha2 || sha1 != SHA256Hex(body) {
23 t.Fatalf("sha mismatch: %s %s", sha1, sha2)
24 }
25 got, _, err := st.Get(ctx, BlobKey("bab", "platform", "prompts", sha1))
26 if err != nil || string(got) != string(body) {
27 t.Fatalf("stored blob: %q %v", got, err)
28 }
29}
30
31func TestPutBlobRejectsOversize(t *testing.T) {
32 st := release.NewDirStore(t.TempDir())
33 if _, err := PutBlob(context.Background(), st, "bab", "platform", "prompts",
34 make([]byte, MaxBlob+1)); err == nil {
35 t.Fatal("oversized blob accepted")
36 }
37}
38