38 lines
1.7 KiB
Go
38 lines
1.7 KiB
Go
package dto
|
|
|
|
import (
|
|
"encoding/json"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestGamePluginRuntimeProfilesBodyRejectsLegacyServerDeployments(t *testing.T) {
|
|
body := GamePluginRuntimeProfilesBody{ServerDeployments: json.RawMessage(`[{"key":"legacy"}]`)}
|
|
|
|
violations := body.UnsupportedLegacyProfileViolations("runtimeProfiles")
|
|
if len(violations) != 1 || !strings.Contains(violations[0], "runtimeProfiles.serverDeployments is no longer supported") {
|
|
t.Fatalf("expected legacy serverDeployments violation, got %v", violations)
|
|
}
|
|
}
|
|
|
|
func TestGamePluginRuntimeProfilesBodyRejectsLegacyClientManagers(t *testing.T) {
|
|
body := GamePluginRuntimeProfilesBody{ClientManagers: json.RawMessage(`[{"key":"legacy"}]`), LifecycleProfiles: []RuntimeLifecycleProfileBody{{Key: "local", ClientManagerRef: json.RawMessage(`{"key":"legacy"}`)}}}
|
|
|
|
violations := body.UnsupportedLegacyProfileViolations("manifest.runtimeProfiles")
|
|
if len(violations) != 2 || !strings.Contains(strings.Join(violations, "; "), "clientManagers is no longer supported") || !strings.Contains(strings.Join(violations, "; "), "clientManagerRef is no longer supported") {
|
|
t.Fatalf("expected legacy client manager violations, got %v", violations)
|
|
}
|
|
}
|
|
|
|
func TestGamePluginRuntimeProfilesBodyRejectsLegacyClientManagersWhenNull(t *testing.T) {
|
|
var body GamePluginRuntimeProfilesBody
|
|
if err := json.Unmarshal([]byte(`{"clientManagers":null}`), &body); err != nil {
|
|
t.Fatalf("decode runtime profile body: %v", err)
|
|
}
|
|
|
|
violations := body.UnsupportedLegacyProfileViolations("runtimeProfiles")
|
|
if len(violations) != 1 || !strings.Contains(violations[0], "runtimeProfiles.clientManagers is no longer supported") {
|
|
t.Fatalf("expected legacy clientManagers null violation, got %v", violations)
|
|
}
|
|
}
|