Adds internal/domain/image (Provider/Registry per the plugin engine family shape, but no Lifecycle -- a provider is call-scoped, not long-running) and config.ImageConfig with the same explicit enabled=true cost gate MinimaxConfig already uses, since a hosted provider spends real API credits and a local one can saturate the host GPU. Design doc at docs/prds/image-capability-contract.md per CLAUDE.md's rule for undesigned capabilities. No provider implementation lands here -- that's the epic's next child bead. Also re-links all 7 epic children that were unlinked from archie-core-1786748942120-1-6636e629 (same orphaning pattern found in the curator/memory epics earlier this session).
69 lines
1.8 KiB
Go
69 lines
1.8 KiB
Go
package image
|
|
|
|
import "testing"
|
|
|
|
func TestCapabilityValidateRejectsEditWithoutInputs(t *testing.T) {
|
|
t.Parallel()
|
|
c := Capability{Edit: true, MaxInputs: 0}
|
|
if err := c.Validate(); err == nil {
|
|
t.Fatal("Validate() = nil, want error for edit with MaxInputs 0")
|
|
}
|
|
}
|
|
|
|
func TestCapabilityValidateRejectsMaskWithoutEdit(t *testing.T) {
|
|
t.Parallel()
|
|
c := Capability{Mask: true}
|
|
if err := c.Validate(); err == nil {
|
|
t.Fatal("Validate() = nil, want error for mask without edit")
|
|
}
|
|
}
|
|
|
|
func TestCapabilityValidateAcceptsGenerateOnly(t *testing.T) {
|
|
t.Parallel()
|
|
c := Capability{Generate: true}
|
|
if err := c.Validate(); err != nil {
|
|
t.Fatalf("Validate() = %v, want nil", err)
|
|
}
|
|
}
|
|
|
|
func TestCapabilityValidateAcceptsEditWithMask(t *testing.T) {
|
|
t.Parallel()
|
|
c := Capability{Edit: true, MaxInputs: 1, Mask: true}
|
|
if err := c.Validate(); err != nil {
|
|
t.Fatalf("Validate() = %v, want nil", err)
|
|
}
|
|
}
|
|
|
|
func TestGenerateRequestValidateRequiresPrompt(t *testing.T) {
|
|
t.Parallel()
|
|
if err := (GenerateRequest{}).Validate(); err == nil {
|
|
t.Fatal("Validate() = nil, want error for empty prompt")
|
|
}
|
|
if err := (GenerateRequest{Prompt: "a cat"}).Validate(); err != nil {
|
|
t.Fatalf("Validate() = %v, want nil", err)
|
|
}
|
|
}
|
|
|
|
func TestEditRequestValidateRequiresPromptAndInputs(t *testing.T) {
|
|
t.Parallel()
|
|
cases := []struct {
|
|
name string
|
|
req EditRequest
|
|
want bool // true if a valid request
|
|
}{
|
|
{"empty", EditRequest{}, false},
|
|
{"no inputs", EditRequest{Prompt: "add a hat"}, false},
|
|
{"no prompt", EditRequest{Inputs: []ImageData{{Bytes: []byte("x")}}}, false},
|
|
{"valid", EditRequest{Prompt: "add a hat", Inputs: []ImageData{{Bytes: []byte("x")}}}, true},
|
|
}
|
|
for _, tc := range cases {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
t.Parallel()
|
|
err := tc.req.Validate()
|
|
if (err == nil) != tc.want {
|
|
t.Fatalf("Validate() = %v, want valid=%v", err, tc.want)
|
|
}
|
|
})
|
|
}
|
|
}
|