carlos / platform Public

Clone
git clone https://amadan.net/carlos/platform

Plain git — no account needed to clone.

Download

Download this file

1package hostbox
2
3import (
4 "bytes"
5 "github.com/carlosframework/platform/internal/registry"
6 "testing"
7)
8
9func TestPlan14UnitInputsProtocol(t *testing.T) {
10 q := RoleLaunchRequest{V: RoleLaunchV, Op: RoleLaunchInputs, Route: &registry.Route{Host: "shop.example", Unit: "console.service"}}
11 raw, err := EncodeRoleLaunchRequest(q)
12 if err != nil {
13 t.Fatal(err)
14 }
15 decoded, err := DecodeRoleLaunchRequest(bytes.NewReader(raw))
16 if err != nil || decoded.Route.Unit != q.Route.Unit {
17 t.Fatal(decoded, err)
18 }
19 for _, mutate := range []func(*RoleLaunchRequest){
20 func(q *RoleLaunchRequest) { q.Route = nil }, func(q *RoleLaunchRequest) { q.Op = RoleLaunchCapability },
21 func(q *RoleLaunchRequest) { q.Op = RoleLaunchStop }, func(q *RoleLaunchRequest) { q.MemoryMax = 1 },
22 func(q *RoleLaunchRequest) { q.Executable = "/app" }, func(q *RoleLaunchRequest) { q.Kind = "serving" }, func(q *RoleLaunchRequest) { q.Spec = &LaunchSpec{} },
23 } {
24 bad := q
25 mutate(&bad)
26 if bad.Validate() == nil {
27 t.Fatal("mixed protocol request accepted", bad)
28 }
29 }
30}
31