Skip to content

Commit 46331be

Browse files
feat: add validate script
1 parent 850b4e6 commit 46331be

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@ Use como input os links abaixo (~1000 registros cada):
146146
- https://storage.googleapis.com/juntossomosmais-code-challenge/input-backend.csv
147147
- https://storage.googleapis.com/juntossomosmais-code-challenge/input-backend.json
148148

149+
## Validação
150+
151+
O arquivo [validate.sh](./validate.sh) contém um teste mínimo da chamada da API. O teste só será avaliado se a API for validada corretamente com esse script.
152+
149153

150154
# Como entregar
151155

@@ -161,7 +165,7 @@ Assim que finalizar, nos avise pelo e-mail [email protected] com:
161165

162166
Em seguinda enviaremos o(s) usuário(s) do github que você deve liberar acesso ao código.
163167

164-
O prazo para envio é de 10 dias, mas se precisar de mais tempo é só nos avisar 😊
168+
O prazo para envio é de 7 dias, mas se precisar de mais tempo é só nos avisar 😊
165169

166170
## Outros desafios
167171

validate.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
API_URL="http://localhost:8080/api/v1/users?pageNumber=1&pageSize=10"
4+
5+
# Make the API call and capture the response
6+
response=$(curl -s --location $API_URL)
7+
8+
# Validate the response body structure using grep and awk
9+
if echo "$response" | grep -q '"pageNumber"' && \
10+
echo "$response" | grep -q '"pageSize"' && \
11+
echo "$response" | grep -q '"totalCount"' && \
12+
echo "$response" | grep -q '2000' && \
13+
echo "$response" | grep -q '"users"' && \
14+
echo "$response" | awk '/"users": \[/ {flag=1; next} /]/ {flag=0} flag {print}' | grep -q '.'; then
15+
echo "Response body is valid."
16+
else
17+
echo "Response body is invalid."
18+
fi

0 commit comments

Comments
 (0)