功能修改
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"browser.local/platform/domain"
|
||||
@@ -17,6 +18,9 @@ func TestTableNames(t *testing.T) {
|
||||
Artifact{}.TableName(): "artifacts",
|
||||
LogStream{}.TableName(): "log_streams",
|
||||
AuditEvent{}.TableName(): "audit_events",
|
||||
Alert{}.TableName(): "alerts",
|
||||
PluginLifecycleInstallation{}.TableName(): "plugin_lifecycle_installations",
|
||||
AIConfigDiff{}.TableName(): "ai_config_diffs",
|
||||
ClientManagerInstallation{}.TableName(): "client_manager_installations",
|
||||
ClientManagerSession{}.TableName(): "client_manager_sessions",
|
||||
ClientManagerRegistrationNonce{}.TableName(): "client_manager_registration_nonces",
|
||||
@@ -43,8 +47,13 @@ func TestGamePluginModelRoundTripCopiesSlices(t *testing.T) {
|
||||
Pages: []domain.GamePluginPage{
|
||||
{Key: "logs", Title: "Logs", Path: "/logs", Permissions: []string{"server.logs.read"}},
|
||||
},
|
||||
Tags: []string{"survival"},
|
||||
AIPurposes: []string{"logs.diagnose"},
|
||||
Tags: []string{"survival"},
|
||||
AIPurposes: []string{"logs.diagnose"},
|
||||
ProductionLifecycle: domain.GamePluginProductionLifecycle{
|
||||
Operations: []string{"install", "upgrade", "rollback"},
|
||||
DependencyPolicy: "required",
|
||||
ApprovalRequired: []string{"rollback"},
|
||||
},
|
||||
RuntimeProfiles: domain.GamePluginRuntimeProfiles{LifecycleProfiles: []domain.RuntimeLifecycleProfile{{Key: "local", Mode: "local-process", Capabilities: []string{"process.start"}}}},
|
||||
Permissions: domain.PluginPermissions{
|
||||
Jobs: true,
|
||||
@@ -61,6 +70,8 @@ func TestGamePluginModelRoundTripCopiesSlices(t *testing.T) {
|
||||
roundTrip.Pages[0].Permissions[0] = "ai.invoke"
|
||||
roundTrip.Tags[0] = "mutated"
|
||||
roundTrip.AIPurposes[0] = "config.suggest"
|
||||
roundTrip.ProductionLifecycle.Operations[0] = "retire"
|
||||
roundTrip.ProductionLifecycle.ApprovalRequired[0] = "disable"
|
||||
roundTrip.RuntimeProfiles.LifecycleProfiles[0].Capabilities[0] = "process.stop"
|
||||
|
||||
if source.RequiredRunCapabilities[0] != "process.start" {
|
||||
@@ -75,11 +86,45 @@ func TestGamePluginModelRoundTripCopiesSlices(t *testing.T) {
|
||||
if row.DeclaredPermissions[0] != "server.logs.read" || row.Pages[0].Permissions[0] != "server.logs.read" || row.Tags[0] != "survival" || row.AIPurposes[0] != "logs.diagnose" {
|
||||
t.Fatalf("expected model plugin registry metadata to remain unchanged, got %+v", row)
|
||||
}
|
||||
if source.ProductionLifecycle.Operations[0] != "install" || row.ProductionLifecycle.Operations[0] != "install" || source.ProductionLifecycle.ApprovalRequired[0] != "rollback" || row.ProductionLifecycle.ApprovalRequired[0] != "rollback" {
|
||||
t.Fatalf("expected production lifecycle declaration to round-trip without aliasing, source=%+v row=%+v", source.ProductionLifecycle, row.ProductionLifecycle)
|
||||
}
|
||||
if source.RuntimeProfiles.LifecycleProfiles[0].Capabilities[0] != "process.start" || row.RuntimeProfiles.LifecycleProfiles[0].Capabilities[0] != "process.start" {
|
||||
t.Fatalf("expected runtime profiles to round-trip without aliasing, source=%+v row=%+v", source.RuntimeProfiles, row.RuntimeProfiles)
|
||||
}
|
||||
}
|
||||
|
||||
func TestJobExecutionInputModelRoundTripPreservesLifecycleMetadata(t *testing.T) {
|
||||
source := domain.JobExecutionInput{
|
||||
WorkspaceScope: "server-workspace",
|
||||
PluginID: "game.scum",
|
||||
LifecycleOperation: "upgrade",
|
||||
TargetVersion: "2.0.0",
|
||||
Inputs: map[string]string{"templateKey": "players.by-id", "playerId": "steam-123"},
|
||||
}
|
||||
|
||||
row := executionInputFromDomain(source)
|
||||
source.Inputs["playerId"] = "source-mutated"
|
||||
if row.Inputs["playerId"] != "steam-123" {
|
||||
t.Fatalf("expected model execution inputs to be isolated from source mutation, row=%+v", row.Inputs)
|
||||
}
|
||||
source.Inputs["playerId"] = "steam-123"
|
||||
row.Inputs["playerId"] = "row-mutated"
|
||||
if source.Inputs["playerId"] != "steam-123" {
|
||||
t.Fatalf("expected source execution inputs to be isolated from model mutation, source=%+v", source.Inputs)
|
||||
}
|
||||
row.Inputs["playerId"] = "steam-123"
|
||||
|
||||
roundTrip := row.ToDomain()
|
||||
if !reflect.DeepEqual(roundTrip, source) {
|
||||
t.Fatalf("expected lifecycle execution metadata to round-trip, got %+v", roundTrip)
|
||||
}
|
||||
roundTrip.Inputs["playerId"] = "mutated"
|
||||
if source.Inputs["playerId"] != "steam-123" || row.Inputs["playerId"] != "steam-123" {
|
||||
t.Fatalf("expected execution inputs to round-trip without aliasing, source=%+v row=%+v", source.Inputs, row.Inputs)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAIProviderModelUsesKeyReference(t *testing.T) {
|
||||
source := domain.AIProvider{
|
||||
ID: "ai.openai",
|
||||
|
||||
Reference in New Issue
Block a user