You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
as there are a lot of tests failing I just want to give an example of the first one
Conduit
❏ Auth
↳ Register
POST [http://app-api:80/api/v1/users](http://app-api/api/v1/users) [201 Created, 193B, 120ms]
┌
| response:
│ 'user:', {
│ email: 'u1651955558@mail.com',
│ username: 'u1651955558'
│ }
└
✓ Response contains "user" property
✓ User has "email" property
✓ User has "username" property
1. User has "bio" property
2. User has "image" property
3. User has "token" property
[...]
# failure detail
001. AssertionError User has "bio" property
expected false to be truthy
at assertion:3 in test-script
inside "Auth / Register"
002. AssertionError User has "image" property
expected false to be truthy
at assertion:4 in test-script
inside "Auth / Register"
003. AssertionError User has "token" property
expected false to be truthy
at assertion:5 in test-script
inside "Auth / Register"
the response json was custome added in the collection via "console.log(\"user:\", user);",
when I change the server/user.go beginning in line 69 to e.g.
---
apiVersion: batch/v1kind: Jobmetadata:
name: check-app-api-newmanspec:
backoffLimit: 0template:
metadata:
labels:
app: check-app-api-newmanspec:
initContainers:
- name: testsimage: tests-tilt-refenv:
- name: APP_API_HOSTvalue: app-api
- name: APP_API_PORTvalue: "80"
- name: API_PATHvalue: /api/v1command:
- ash
- -c
- | set -o errexit set -o nounset # set -o xtrace if set +o | grep -F 'set +o pipefail' > /dev/null; then # shellcheck disable=SC3040 set -o pipefail fi if set +o | grep -F 'set +o posix' > /dev/null; then # shellcheck disable=SC3040 set -o posix fi export APIURL=http://${APP_API_HOST}:${APP_API_PORT}${API_PATH} func_curl_check_endpoint() { TEST_ENDPOINT=${1:-http://localhost:80/healthz} echo "test endpoint: ${TEST_ENDPOINT}" curl -v --fail --silent -o /dev/null -X 'GET' \ --connect-timeout 1 \ --max-time 5 \ --retry 60 \ --retry-delay 1 \ --retry-max-time 120 \ "${TEST_ENDPOINT}" \ -H 'accept: application/json' } func_curl_check_endpoint "${APIURL}/health" echo api reachable/healthy # === api create user ====================================================== REGISTRATION_JSON=$(cat <<END_HEREDOC { "user":{ "username": "Jacob", "email": "jake@jake.jake", "password": "jakejake" } } END_HEREDOC ) printf 'REGISTRATION_JSON:\n%s\n' "${REGISTRATION_JSON}" # allowed to fail (not perfect but atm easiest way for user-already-exist kind of check) curl -v --header "Content-Type: application/json" \ --request POST \ --data "${REGISTRATION_JSON}" \ "${APIURL}/users" echo "" echo done;containers:
- name: test-api-newmanimage: tests-api-newman-tilt-refenv:
- name: APP_API_HOSTvalue: app-api
- name: APP_API_PORTvalue: "80"
- name: API_PATHvalue: /api/v1# - name: USERNAME# value: Jacob# - name: EMAIL# value: jake@jake.jake# - name: PASSWORD# value: jakejakecommand:
- ash
- -c
- | set -o errexit set -o nounset # set -o xtrace if set +o | grep -F 'set +o pipefail' > /dev/null; then # shellcheck disable=SC3040 set -o pipefail fi if set +o | grep -F 'set +o posix' > /dev/null; then # shellcheck disable=SC3040 set -o posix fi export APIURL=http://${APP_API_HOST}:${APP_API_PORT}${API_PATH} cd /api && ./run-api-tests.sh echo donerestartPolicy: Never
Dockerfile
FROM docker.io/alpine:3.15.4 AS curl-tests
RUN apk update && apk add curl jq
# =============================================================================FROM docker.io/postman/newman:5.3.1-alpine AS api-newman-tests
COPY ./api /api
RUN chmod +x /api/run-api-tests.sh
I created an k8s setup as an exercise and it works pretty well.
However I also added a setup for the newman/postman tests, which shows that the api is not coherent with the spec
as there are a lot of tests failing I just want to give an example of the first one
the response json was custome added in the collection via
"console.log(\"user:\", user);",
when I change the
server/user.go
beginning in line69
to e.g.then the corresponding assertion (bio) succeeds
here is the test k8s job for reference:
Dockerfile
complet setup can be checked here:
https://github.com/pandorasNox/go-realworld
The text was updated successfully, but these errors were encountered: