Phase2
This commit is contained in:
@@ -136,6 +136,69 @@ func TestDecodeEnvelope(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestServerProvisionPayload_JSONRoundtrip(t *testing.T) {
|
||||
deadline := time.Date(2026, 6, 26, 12, 0, 0, 0, time.UTC)
|
||||
original := ServerProvisionPayload{
|
||||
OperationMeta: OperationMeta{
|
||||
ServerID: "srv-abc123",
|
||||
Generation: 2,
|
||||
Deadline: &deadline,
|
||||
IdempotencyKey: "idem-001",
|
||||
},
|
||||
Edition: "JAVA",
|
||||
SoftwareFamily: "PAPER",
|
||||
MinecraftVersion: "1.21.1",
|
||||
HostPort: 25565,
|
||||
RamMb: 2048,
|
||||
DataPath: "/var/lib/hexahost-gamecloud/srv-abc123",
|
||||
EulaAccepted: true,
|
||||
}
|
||||
|
||||
data, err := json.Marshal(original)
|
||||
if err != nil {
|
||||
t.Fatalf("marshal: %v", err)
|
||||
}
|
||||
|
||||
var decoded ServerProvisionPayload
|
||||
if err := json.Unmarshal(data, &decoded); err != nil {
|
||||
t.Fatalf("unmarshal: %v", err)
|
||||
}
|
||||
|
||||
if decoded.ServerID != original.ServerID {
|
||||
t.Fatalf("serverId: got %q want %q", decoded.ServerID, original.ServerID)
|
||||
}
|
||||
if decoded.Generation != original.Generation {
|
||||
t.Fatalf("generation: got %d want %d", decoded.Generation, original.Generation)
|
||||
}
|
||||
if decoded.Edition != original.Edition {
|
||||
t.Fatalf("edition: got %q want %q", decoded.Edition, original.Edition)
|
||||
}
|
||||
if decoded.SoftwareFamily != original.SoftwareFamily {
|
||||
t.Fatalf("softwareFamily: got %q want %q", decoded.SoftwareFamily, original.SoftwareFamily)
|
||||
}
|
||||
if decoded.MinecraftVersion != original.MinecraftVersion {
|
||||
t.Fatalf("minecraftVersion: got %q want %q", decoded.MinecraftVersion, original.MinecraftVersion)
|
||||
}
|
||||
if decoded.HostPort != original.HostPort {
|
||||
t.Fatalf("hostPort: got %d want %d", decoded.HostPort, original.HostPort)
|
||||
}
|
||||
if decoded.RamMb != original.RamMb {
|
||||
t.Fatalf("ramMb: got %d want %d", decoded.RamMb, original.RamMb)
|
||||
}
|
||||
if decoded.DataPath != original.DataPath {
|
||||
t.Fatalf("dataPath: got %q want %q", decoded.DataPath, original.DataPath)
|
||||
}
|
||||
if decoded.EulaAccepted != original.EulaAccepted {
|
||||
t.Fatalf("eulaAccepted: got %v want %v", decoded.EulaAccepted, original.EulaAccepted)
|
||||
}
|
||||
if decoded.IdempotencyKey != original.IdempotencyKey {
|
||||
t.Fatalf("idempotencyKey: got %q want %q", decoded.IdempotencyKey, original.IdempotencyKey)
|
||||
}
|
||||
if decoded.Deadline == nil || !decoded.Deadline.Equal(deadline) {
|
||||
t.Fatalf("deadline mismatch: got %v want %v", decoded.Deadline, deadline)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewEnvelope(t *testing.T) {
|
||||
env, err := NewEnvelope(TypeAgentHello, "msg-new", AgentHelloPayload{
|
||||
NodeID: "n1",
|
||||
|
||||
Reference in New Issue
Block a user