Files
llmgw/internal/store/presets_test.go
T
Ilker ManapandClaude Opus 5.5 f42af27da5 The leader adds the picture and 3D presets a node fits, unless told not to
A customer's portal had no Images or 3D pages: nobody had written a
definition for either, on a cluster whose V100 runs both. The leading
control plane now adds flux-schnell and triposr, on demand, once a node
has a card that fits one, the cluster installs ComfyUI, and the catalog
makes nothing of that kind. presets.auto (a live setting, on by default)
turns it off; a preset somebody removes is recorded as declined and not
added back until added again by hand. Each addition is in the audit log.

GET /api/v1/presets says how each preset stands, the ComfyUI the cluster
installs, and why one is not added; POST /api/v1/presets/{name} adds one
(setting engines.comfyui where there is none); PUT /api/v1/presets/auto
switches it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-13 20:48:40 +02:00

40 lines
1.2 KiB
Go

package store
import (
"testing"
"time"
)
func TestAPresetDeclinedStaysSoUntilAddedAgain(t *testing.T) {
db := openDB(t)
ctx := t.Context()
at := time.Date(2026, 10, 13, 12, 0, 0, 0, time.UTC)
if err := db.PresetAdded(ctx, "triposr", PresetAdder, at); err != nil {
t.Fatal(err)
}
if err := db.PresetDeclined(ctx, "triposr", "ops@example.com", at.Add(time.Hour)); err != nil {
t.Fatal(err)
}
// Removed before it was ever added as a preset: declined all the same.
if err := db.PresetDeclined(ctx, "flux-schnell", "ops@example.com", at); err != nil {
t.Fatal(err)
}
got, err := db.PresetStates(ctx)
if err != nil {
t.Fatal(err)
}
if p := got["triposr"]; p.AddedBy != PresetAdder || !p.AddedAt.Equal(at) || !p.Declined || p.DeclinedBy != "ops@example.com" {
t.Errorf("triposr %+v", p)
}
if p := got["flux-schnell"]; !p.Declined || p.AddedBy != "" || !p.AddedAt.IsZero() {
t.Errorf("flux %+v", p)
}
if err := db.PresetAdded(ctx, "triposr", "ops@example.com", at.Add(2*time.Hour)); err != nil {
t.Fatal(err)
}
got, _ = db.PresetStates(ctx)
if p := got["triposr"]; p.Declined || p.AddedBy != "ops@example.com" || !p.DeclinedAt.IsZero() {
t.Errorf("added again, %+v", p)
}
}