Download this file
| 1 | package hostbox |
| 2 | |
| 3 | import ( |
| 4 | "bytes" |
| 5 | "github.com/carlosframework/platform/internal/registry" |
| 6 | "testing" |
| 7 | ) |
| 8 | |
| 9 | func TestPlan14UnitInputsProtocol(t *testing.T) { |
| 10 | q := RoleLaunchRequest{V: RoleLaunchV, Op: RoleLaunchInputs, Route: ®istry.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 | |