chore: establish local platform baseline
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
package saas
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"data-terminal-cloud/internal/audit"
|
||||
"data-terminal-cloud/internal/identity"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
)
|
||||
|
||||
func TestConversationReadinessReflectsSeedFacts(t *testing.T) {
|
||||
databaseURL := os.Getenv("TEST_DATABASE_URL")
|
||||
if databaseURL == "" {
|
||||
t.Skip("TEST_DATABASE_URL is not set")
|
||||
}
|
||||
pool, err := pgxpool.New(context.Background(), databaseURL)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer pool.Close()
|
||||
|
||||
service := NewService(pool, audit.NewRepository(), nil, nil)
|
||||
principal := identity.Principal{Issuer: "http://localhost:58180/realms/voice-local", Subject: "00000000-0000-0000-0000-000000000101"}
|
||||
result, err := service.GetConversationReadiness(context.Background(), principal, "10000000-0000-0000-0000-000000000411")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
checks := make(map[string]ConversationReadinessCheck, len(result.Checks))
|
||||
for _, check := range result.Checks {
|
||||
checks[check.Code] = check
|
||||
}
|
||||
if result.Ready || checks["PROFILE_BACKGROUND"].Status != "blocked" || checks["CONVERSATION_GOAL"].Status != "blocked" {
|
||||
t.Fatalf("expected incomplete seed profile to block readiness: %#v", result)
|
||||
}
|
||||
if checks["VOICE_CONSENT"].Status != "ready" || checks["DEVICE_BOUND"].Status != "ready" || checks["DEVICE_RUNTIME"].Status != "ready" || checks["FIRMWARE_POLICY"].Status != "ready" {
|
||||
t.Fatalf("expected seeded consent and device to be ready: %#v", checks)
|
||||
}
|
||||
if len(result.Devices) != 1 || result.Devices[0].ID != "10000000-0000-0000-0000-000000000511" {
|
||||
t.Fatalf("unexpected readiness devices: %#v", result.Devices)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user