@@ -12,25 +12,35 @@ INTEGRATION_TESTS_DIR="${REPOSITORY_ROOT:?}"/tests/integration
12
12
LOCAL_RUN_DIR=" ${REPOSITORY_ROOT:? } " /local-run
13
13
LOCAL_RUN_SCRIPTS=" ${LOCAL_RUN_DIR:? } " /scripts
14
14
BASE_SCENARIO_NAME=demo
15
+ : ${INTEGRATION_TEST_HOST:= http:// 127.0.0.1: 8080}
15
16
16
17
SCENARIO_NAME=" ${BASE_SCENARIO_NAME:? } -$( date +%s) "
17
18
# Compute dynamic variables.
18
19
source " ${LOCAL_RUN_SCRIPTS:? } " /scenario-files.sh
19
20
21
+ abort () {
22
+ # Do not stop the API after a failure to allow investigation.
23
+ # NOTE: In the CI, it will be stopped anyway so it’s perfect.
24
+ task integration-test:logs
25
+ die " $@ "
26
+ }
27
+
20
28
info ' Starting the demo API (already populated with data)…'
21
29
edo task local:run -- --detach --api=local --scenario=" ${BASE_SCENARIO_NAME:? } " --ephemeral --ephemeral-name=" ${SCENARIO_NAME:? } " --no-update
22
30
31
+ # Wait a bit to make sure the API is ready (e.g. has run migrations).
32
+ sleep 1
33
+
23
34
info Logging an admin in…
24
- TOKEN=
" $( edo curl -s -X POST http://localhost:8080/v1/login -u ' [email protected] :demo' \| jq -r ' .token' ) "
35
+ TOKEN=
" $( xh POST -I " ${INTEGRATION_TEST_HOST:? } " /v1/login -a ' [email protected] :demo' content-type: | jq -r ' .token' ) "
36
+ [ -n " ${TOKEN-} " ] && [ " ${TOKEN:? } " != null ] || abort
25
37
26
38
info Getting the factory reset token…
27
- CONFIRMATION=" $( edo curl -s -X DELETE http://localhost:8080 -H " Authorization: Bearer ${TOKEN:? } " \| jq -r ' .confirmation' ) "
39
+ CONFIRMATION=" $( xh DELETE -I " ${INTEGRATION_TEST_HOST:? } " -A bearer -a " ${TOKEN:? } " | jq -r ' .confirmation' ) "
40
+ [ -n " ${CONFIRMATION-} " ] && [ " ${CONFIRMATION:? } " != null ] || abort
28
41
29
42
info Performing the factory reset…
30
- edo curl -s -X DELETE http://localhost:8080 \
31
- -H " Authorization: Bearer ${TOKEN:? } " \
32
- -H " Content-Type: application/json" \
33
- -d ' {"confirmation": "' " ${CONFIRMATION:? } " ' "}'
43
+ edo xh DELETE -Iq " ${INTEGRATION_TEST_HOST:? } " -A bearer -a " ${TOKEN:? } " confirmation=" ${CONFIRMATION:? } " || abort
34
44
35
45
info Checking if factory reset deleted everything…
36
46
82
92
success API config file reset
83
93
84
94
info Waiting for the API to restart…
85
- edo curl http://localhost:8080/ api-docs/openapi.json --retry 3 --fail -s --output /dev/null || die API stuck restarting.
95
+ edo log_as_trace_ xh GET -Iq " ${INTEGRATION_TEST_HOST :? } " / api-docs/openapi.json --timeout 3 -p=HBhm || abort API stuck restarting.
86
96
87
97
info Checking if the API still works…
88
98
# Run the `init` integration test, which will initialize the Pod
89
- # (saving us a bunch of `curl` commands).
99
+ # (saving us a bunch of `curl`/`xh` commands).
90
100
( export SKIP_POD_START=1 SKIP_POD_STOP=1; edo log_as_trace_ task integration-test -- init )
91
101
success The API still works!
92
102
0 commit comments