diff options
| author | Murilo Ijanc <[email protected]> | 2026-07-27 20:31:13 -0300 |
|---|---|---|
| committer | Murilo Ijanc <[email protected]> | 2026-07-27 20:31:13 -0300 |
| commit | 42e586658b4bc39542a5311842f0040f7d29cb2b (patch) | |
| tree | bd66cccfb74235cf10449e83c4b78b38b487349d /tests/Cepis.Tests/Fixtures.cs | |
| parent | a2b10fd494fb389e556e40134031eb86e56e11e7 (diff) | |
| download | csharp-42e586658b4bc39542a5311842f0040f7d29cb2b.tar.gz | |
The API now hangs an optional faixa block off the 404 of GET /{cep}, and
this exposes it as CepNotFoundException.Faixa. A CEP that fails is rarely
random: it is usually someone who knows the city and guessed the number,
most often the -000 that 957 municipalities never received. Knowing where
the guess landed turns a dead-end "CEP not found" into a question worth
asking the user.
It stays an error. The block names the municipality the number would
belong to, never an address, and the lookup still throws. CepIni and
CepFim are the smallest and largest CEP that actually exist there, not the
range the Correios publish — the published start for Areal is 25845000,
exactly the CEP that fails — and the interval between them is sparse,
which is what Ceps is for.
Parsing is deliberately toothless: absent, misshapen or nameless, the
block becomes null and the caller gets the same clean not-found it got
before the field existed. A courtesy on top of a 404 must never be able to
turn it into a parse failure.
Diffstat (limited to 'tests/Cepis.Tests/Fixtures.cs')
| -rw-r--r-- | tests/Cepis.Tests/Fixtures.cs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/Cepis.Tests/Fixtures.cs b/tests/Cepis.Tests/Fixtures.cs index 648f881..a7e69b3 100644 --- a/tests/Cepis.Tests/Fixtures.cs +++ b/tests/Cepis.Tests/Fixtures.cs @@ -40,6 +40,30 @@ public static class Fixtures public const string NotFound = """{"erro":"cep_nao_encontrado","mensagem":"CEP não existe na base do DNE"}"""; + /// <summary> + /// The 404 body for a CEP inside a municipality's range. The CEP that draws + /// it is 25845000 — the DNE's own start for Areal, and a CEP that was never + /// issued. + /// </summary> + public const string NotFoundWithFaixa = """ + {"erro":"cep_nao_encontrado","mensagem":"CEP não existe na base do DNE", + "faixa":{"localidade":"Areal","uf":"RJ","estado":"Rio de Janeiro", + "regiao":"Sudeste","ibge":"3300225","cep_ini":"25845001", + "cep_fim":"25849899","ceps":118}} + """; + + /// <summary>A 404 whose range block is not even an object.</summary> + public const string NotFoundBrokenFaixa = """ + {"erro":"cep_nao_encontrado","mensagem":"CEP não existe na base do DNE", + "faixa":"Areal"} + """; + + /// <summary>A 404 whose range block names no municipality.</summary> + public const string NotFoundNamelessFaixa = """ + {"erro":"cep_nao_encontrado","mensagem":"CEP não existe na base do DNE", + "faixa":{"uf":"RJ","cep_ini":"25845001","cep_fim":"25849899","ceps":118}} + """; + /// <summary>The 400 body.</summary> public const string InvalidCep = """{"erro":"cep_invalido","mensagem":"CEP deve ter 8 dígitos"}"""; |