Files
Agent-System/internal/bizdev/materials_test.go
T
weichen 3145550a59 feat(security): complete P0 release blocking remediation
Unify auth middleware and remove X-User-ID trust, add project_members
authorization, sandbox workspaces via resolver, and admin-only reconcile
by run_id. Introduce goose migrations with startup schema gate, fail closed
when DB unavailable outside explicit ALLOW_IN_MEMORY, bundle web/dist in
app Dockerfile, and remove frontend pseudo-login fallback.
2026-09-13 02:50:22 +00:00

61 lines
1.9 KiB
Go

package bizdev_test
import (
"context"
"testing"
"chat-agent-system/internal/bizdev"
"chat-agent-system/internal/config"
)
func TestResolveMaterials_InlineText(t *testing.T) {
cfg := &config.Config{DataDir: t.TempDir()}
svc := bizdev.MustNewService(t, cfg)
materials, manifest, err := svc.ResolveMaterials(context.Background(), bizdev.TaskRunRequest{
Materials: []bizdev.MaterialInput{
{Filename: "req.txt", Content: []byte("hello project requirements")},
},
})
if err != nil {
t.Fatalf("ResolveMaterials failed: %v", err)
}
if len(materials) != 1 || string(materials[0].Content) != "hello project requirements" {
t.Fatalf("unexpected materials: %+v", materials)
}
if manifest["resolved_count"] != 1 {
t.Fatalf("manifest=%v", manifest)
}
}
func TestResolveMaterials_RejectEmptyBinary(t *testing.T) {
cfg := &config.Config{DataDir: t.TempDir()}
svc := bizdev.MustNewService(t, cfg)
_, _, err := svc.ResolveMaterials(context.Background(), bizdev.TaskRunRequest{
Materials: []bizdev.MaterialInput{{Filename: "empty.docx", Content: nil}},
})
if err == nil {
t.Fatal("expected error for empty binary material")
}
}
func TestResolveMaterials_ProjectAssetPool(t *testing.T) {
cfg := &config.Config{DataDir: t.TempDir()}
svc := bizdev.MustNewService(t, cfg)
cas := svc.CAS()
ref, err := cas.StoreFile(context.Background(), 42, 1, "pool.txt", "material", []byte("pool asset body"), "text/plain")
if err != nil {
t.Fatalf("StoreFile failed: %v", err)
}
_ = ref
materials, manifest, err := svc.ResolveMaterials(context.Background(), bizdev.TaskRunRequest{ProjectID: 42})
if err != nil {
t.Fatalf("ResolveMaterials failed: %v", err)
}
if len(materials) != 1 || string(materials[0].Content) != "pool asset body" {
t.Fatalf("materials=%+v", materials)
}
if manifest["project_assets"] == nil {
t.Fatalf("expected project_assets in manifest, got %v", manifest)
}
}