Skip to content

Refactor weather tests to use setup function - #62

Open
teobaldotech wants to merge 1 commit into
robertoduessmann:masterfrom
teobaldotech:patch-2
Open

teobaldotech wants to merge 1 commit into
robertoduessmann:masterfrom
teobaldotech:patch-2

Conversation

@teobaldotech

Copy link
Copy Markdown

O código é uma suíte de testes em Go para validar o comportamento do endpoint responsável por consultar o clima atual de uma cidade. Ele utiliza testing, httptest, encoding/json e gorilla/mux.

A principal melhoria foi aplicar o princípio F.I.R.S.T., tornando os testes mais rápidos, independentes, repetíveis, autovalidáveis e escritos de forma próxima ao comportamento que precisam verificar.

O código é uma suíte de testes em Go para validar o comportamento do endpoint responsável por consultar o clima atual de uma cidade. Ele utiliza testing, httptest, encoding/json e gorilla/mux.

A principal melhoria foi aplicar o princípio F.I.R.S.T., tornando os testes mais rápidos, independentes, repetíveis, autovalidáveis e escritos de forma próxima ao comportamento que precisam verificar.
@teobaldotech

Copy link
Copy Markdown
Author

Os testes foram revisados e estruturados seguindo o princípio F.I.R.S.T., proporcionando uma suíte mais rápida, independente, repetível, autovalidável e alinhada ao comportamento do endpoint. A criação do router foi centralizada para reduzir duplicação, os testes utilizam httptest para evitar dependências de um servidor HTTP real e foram adicionados cenários para sucesso, cidade não encontrada, método HTTP não permitido e rota inexistente.

Comment on lines +65 to +66
// TestNotFoundWeather verifica se uma cidade inexistente
// retorna HTTP 404.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just trying to keep the codebase in english

Suggested change
// TestNotFoundWeather verifica se uma cidade inexistente
// retorna HTTP 404.
// TestNotFoundWeather check if not found city returns 404

Comment on lines +91 to +92
// TestCurrentWeatherMethodNotAllowed verifica se métodos
// diferentes de GET são rejeitados.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// TestCurrentWeatherMethodNotAllowed verifica se métodos
// diferentes de GET são rejeitados.
// TestCurrentWeatherMethodNotAllowed check if methods other than GET are rejected.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants