MED-5 — response enum policy for GA (see docs/api.md "Versioning & stability"): - A field whose value set is genuinely closed forever (direction: a message is inbound or outbound, period) carries a closed enum. - A field whose value set the server may grow (delivery/review/send/event status, sending
(t *testing.T)
| 152 | // This test pins both halves so neither regresses: an open field must not silently |
| 153 | // re-acquire a closed enum, and direction must not lose its enum. |
| 154 | func TestSpecStatusEnums(t *testing.T) { |
| 155 | doc := renderSpec(t) |
| 156 | |
| 157 | // Closed-forever enums (must carry the exact enum). |
| 158 | closed := []struct { |
| 159 | schema string |
| 160 | field string |
| 161 | want []string |
| 162 | }{ |
| 163 | {"MessageView", "direction", []string{"inbound", "outbound"}}, |
| 164 | {"MessageSummaryView", "direction", []string{"inbound", "outbound"}}, |
| 165 | } |
| 166 | for _, c := range closed { |
| 167 | props := schemaProps(t, doc, c.schema) |
| 168 | got := enumOf(props, c.field) |
| 169 | if !setEqual(got, c.want...) { |
| 170 | t.Errorf("%s.%s enum = %v, want closed enum %v", c.schema, c.field, got, c.want) |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | // Open (growable) response fields — must be plain strings with NO enum, so a |
| 175 | // new server value doesn't break a frozen strict client. Re-closing any of |
| 176 | // these is a breaking change for the GA contract. |
| 177 | open := []struct { |
| 178 | schema string |
| 179 | field string |
| 180 | }{ |
| 181 | {"MessageView", "review_status"}, |
| 182 | {"MessageSummaryView", "review_status"}, |
| 183 | {"MessageView", "delivery_status"}, |
| 184 | {"MessageSummaryView", "delivery_status"}, |
| 185 | {"MessageView", "sent_as"}, |
| 186 | {"MessageSummaryView", "sent_as"}, |
| 187 | {"SendResultView", "status"}, |
| 188 | {"SendResultView", "sent_as"}, |
| 189 | {"SendResultView", "method"}, |
| 190 | {"EventJSON", "status"}, |
| 191 | {"EventJSON", "type"}, |
| 192 | {"RedeliverView", "status"}, |
| 193 | {"RedeliverDelivery", "status"}, |
| 194 | {"WebhookDeliveryView", "status"}, |
| 195 | {"WebhookDeliveryView", "event_type"}, |
| 196 | {"DomainView", "sending_status"}, |
| 197 | {"ReviewView", "review_status"}, |
| 198 | } |
| 199 | for _, c := range open { |
| 200 | props := schemaProps(t, doc, c.schema) |
| 201 | if got := enumOf(props, c.field); len(got) != 0 { |
| 202 | t.Errorf("%s.%s must be an OPEN string (no enum) for GA forward-compat, but has enum %v", c.schema, c.field, got) |
| 203 | } |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | // MED-6 — Page.items must NOT be nullable. (As of GA blocker #3 every list — |
| 208 | // agents/domains/webhooks/suppressions included — uses the shared Page[T] |
nothing calls this directly
no test coverage detected