Feat v0.8.0 files sandbox module
All checks were successful
CI/CD / detect-changes (pull_request) Successful in 4s
CI/CD / test-frontend (pull_request) Has been skipped
CI/CD / test-runners (pull_request) Has been skipped
CI/CD / e2e-smoke (pull_request) Has been skipped
CI/CD / test-go-pg (pull_request) Successful in 2m44s
CI/CD / test-sqlite (pull_request) Successful in 2m57s
CI/CD / build-and-deploy (pull_request) Successful in 1m25s
All checks were successful
CI/CD / detect-changes (pull_request) Successful in 4s
CI/CD / test-frontend (pull_request) Has been skipped
CI/CD / test-runners (pull_request) Has been skipped
CI/CD / e2e-smoke (pull_request) Has been skipped
CI/CD / test-go-pg (pull_request) Successful in 2m44s
CI/CD / test-sqlite (pull_request) Successful in 2m57s
CI/CD / build-and-deploy (pull_request) Successful in 1m25s
Bridge ObjectStore (PVC/S3) into the Starlark sandbox with extension-scoped key namespacing. New files module with put/get/meta/list/delete/exists builtins gated by files.read and files.write permissions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -282,6 +282,64 @@ func TestPVC_SubdirCreation(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestPVC_List(t *testing.T) {
|
||||
s := tempStore(t)
|
||||
ctx := context.Background()
|
||||
|
||||
// Empty prefix — no files.
|
||||
entries, err := s.List(ctx, "ext/pkg1/", 100)
|
||||
if err != nil {
|
||||
t.Fatalf("List empty: %v", err)
|
||||
}
|
||||
if len(entries) != 0 {
|
||||
t.Errorf("expected 0 entries, got %d", len(entries))
|
||||
}
|
||||
|
||||
// Add some files under a prefix.
|
||||
for _, name := range []string{"a.txt", "b.png", "sub/c.pdf"} {
|
||||
key := "ext/pkg1/" + name
|
||||
_ = s.Put(ctx, key, bytes.NewReader([]byte("x")), 1, "text/plain")
|
||||
}
|
||||
// Add a file under a different prefix.
|
||||
_ = s.Put(ctx, "ext/pkg2/other.txt", bytes.NewReader([]byte("y")), 1, "text/plain")
|
||||
|
||||
// List all under pkg1.
|
||||
entries, err = s.List(ctx, "ext/pkg1/", 100)
|
||||
if err != nil {
|
||||
t.Fatalf("List: %v", err)
|
||||
}
|
||||
if len(entries) != 3 {
|
||||
t.Errorf("expected 3 entries, got %d", len(entries))
|
||||
}
|
||||
|
||||
// List with limit.
|
||||
entries, err = s.List(ctx, "ext/pkg1/", 2)
|
||||
if err != nil {
|
||||
t.Fatalf("List limited: %v", err)
|
||||
}
|
||||
if len(entries) != 2 {
|
||||
t.Errorf("expected 2 entries (limit), got %d", len(entries))
|
||||
}
|
||||
|
||||
// List with sub-prefix.
|
||||
entries, err = s.List(ctx, "ext/pkg1/sub/", 100)
|
||||
if err != nil {
|
||||
t.Fatalf("List sub: %v", err)
|
||||
}
|
||||
if len(entries) != 1 {
|
||||
t.Errorf("expected 1 entry in sub/, got %d", len(entries))
|
||||
}
|
||||
|
||||
// pkg2 prefix should only find 1.
|
||||
entries, err = s.List(ctx, "ext/pkg2/", 100)
|
||||
if err != nil {
|
||||
t.Fatalf("List pkg2: %v", err)
|
||||
}
|
||||
if len(entries) != 1 {
|
||||
t.Errorf("expected 1 entry in pkg2, got %d", len(entries))
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewPVC_InvalidPath(t *testing.T) {
|
||||
// Path that can't be created (nested under a file)
|
||||
tmp := t.TempDir()
|
||||
|
||||
Reference in New Issue
Block a user