oficina / equipo Public

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

Plain git — no account needed to clone.

Download

Download this file

1package wireschema
2
3import (
4 "amadan.net/oficina/equipo/internal/wire"
5 "encoding/json"
6 "testing"
7)
8
9func TestNotificationOperationSchemas(t *testing.T) {
10 if _, ok := Ops["POST /tasks/{id}/retry"].In.(wire.RetryTask); !ok {
11 t.Fatal("retry binding is undocumented")
12 }
13 var answer map[string]any
14 if err := json.Unmarshal(Body(Ops["POST /cards/{id}/answer"].Out["409"]), &answer); err != nil {
15 t.Fatal(err)
16 }
17 alternatives, ok := answer["oneOf"].([]any)
18 if !ok || len(alternatives) != 2 {
19 t.Fatal("card and idempotency conflicts must both be documented", answer)
20 }
21 want := map[string]bool{"#/components/schemas/CardConflict": true, "#/components/schemas/Error": true}
22 for _, entry := range alternatives {
23 delete(want, entry.(map[string]any)["$ref"].(string))
24 }
25 if len(want) != 0 {
26 t.Fatal(want)
27 }
28 raw := Generate()["RegisterPush"]
29 var registration map[string]any
30 if err := json.Unmarshal(raw, &registration); err != nil {
31 t.Fatal(err)
32 }
33 properties := registration["properties"].(map[string]any)
34 for _, key := range []string{"binding_id", "actions_version"} {
35 if properties[key] == nil {
36 t.Fatal(key)
37 }
38 }
39}
40