oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1// Package coordinatorcontract shares recorded, credential-free wire exchanges
2// between the instance handler and runner transport tests.
3package coordinatorcontract
4
5import (
6 "embed"
7 "encoding/json"
8)
9
10//go:embed testdata/*.json
11var files embed.FS
12
13type Packet struct {
14 Path string `json:"path"`
15 Request json.RawMessage `json:"request"`
16 Response json.RawMessage `json:"response"`
17}
18
19func Load(name string) (Packet, error) {
20 var p Packet
21 raw, err := files.ReadFile("testdata/" + name + ".json")
22 if err == nil {
23 err = json.Unmarshal(raw, &p)
24 }
25 return p, err
26}
27func Canonical(raw []byte) string {
28 var v any
29 if json.Unmarshal(raw, &v) != nil {
30 return "invalid JSON"
31 }
32 out, _ := json.Marshal(v)
33 return string(out)
34}
35