2026-10-04 00:45:23 +00:00
|
|
|
package llm
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"errors"
|
|
|
|
|
"testing"
|
|
|
|
|
|
2026-11-23 04:23:59 +00:00
|
|
|
"gitea.maximumdirect.net/eric/audita/v4/internal/appconfig"
|
2026-11-17 19:57:22 +00:00
|
|
|
"gitea.maximumdirect.net/eric/audita/v4/internal/prompts"
|
2026-11-10 18:13:12 +00:00
|
|
|
ck "go.maximumdirect.net/configkit"
|
2026-10-04 00:45:23 +00:00
|
|
|
)
|
|
|
|
|
|
2026-11-23 04:23:59 +00:00
|
|
|
func TestRuntimeCapturesShippedPromptsAndHonorsCancellation(t *testing.T) {
|
|
|
|
|
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.NoSource()}, "")
|
2026-10-04 00:45:23 +00:00
|
|
|
if err != nil {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
}
|
2026-11-23 04:23:59 +00:00
|
|
|
engine, err := NewEngine(context.Background(), loaded, nil)
|
2026-10-04 01:10:10 +00:00
|
|
|
if err != nil {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
}
|
2026-11-23 04:23:59 +00:00
|
|
|
for _, meta := range prompts.RegisteredMetadata() {
|
|
|
|
|
if _, err := engine.InspectPrompt(context.Background(), meta.PromptID); err != nil {
|
|
|
|
|
t.Errorf("inspect %s: %v", meta.PromptID, err)
|
|
|
|
|
}
|
2026-10-04 00:45:23 +00:00
|
|
|
}
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
cancel()
|
2026-11-23 04:23:59 +00:00
|
|
|
if _, err := NewEngine(ctx, loaded, nil); !errors.Is(err, context.Canceled) {
|
|
|
|
|
t.Fatalf("cancellation: %v", err)
|
2026-10-04 00:45:23 +00:00
|
|
|
}
|
|
|
|
|
}
|