Skip to content

Commit 2b9bb1f

Browse files
refactor(tests): switch from prism to steady
1 parent a64b4d1 commit 2b9bb1f

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

scripts/mock

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,34 +19,34 @@ fi
1919

2020
echo "==> Starting mock server with URL ${URL}"
2121

22-
# Run prism mock on the given spec
22+
# Run steady mock on the given spec
2323
if [ "$1" == "--daemon" ]; then
2424
# Pre-install the package so the download doesn't eat into the startup timeout
25-
npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism --version
25+
npm exec --package=@stdy/cli@0.19.3 -- steady --version
2626

27-
npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" &> .prism.log &
27+
npm exec --package=@stdy/cli@0.19.3 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-query-object-format=dots "$URL" &> .stdy.log &
2828

29-
# Wait for server to come online (max 30s)
29+
# Wait for server to come online via health endpoint (max 30s)
3030
echo -n "Waiting for server"
3131
attempts=0
32-
while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do
32+
while ! curl --silent --fail "http://127.0.0.1:4010/_x-steady/health" >/dev/null 2>&1; do
33+
if ! kill -0 $! 2>/dev/null; then
34+
echo
35+
cat .stdy.log
36+
exit 1
37+
fi
3338
attempts=$((attempts + 1))
3439
if [ "$attempts" -ge 300 ]; then
3540
echo
36-
echo "Timed out waiting for Prism server to start"
37-
cat .prism.log
41+
echo "Timed out waiting for Steady server to start"
42+
cat .stdy.log
3843
exit 1
3944
fi
4045
echo -n "."
4146
sleep 0.1
4247
done
4348

44-
if grep -q "✖ fatal" ".prism.log"; then
45-
cat .prism.log
46-
exit 1
47-
fi
48-
4949
echo
5050
else
51-
npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL"
51+
npm exec --package=@stdy/cli@0.19.3 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-query-object-format=dots "$URL"
5252
fi

scripts/test

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ GREEN='\033[0;32m'
99
YELLOW='\033[0;33m'
1010
NC='\033[0m' # No Color
1111

12-
function prism_is_running() {
13-
curl --silent "http://localhost:4010" >/dev/null 2>&1
12+
function steady_is_running() {
13+
curl --silent "http://127.0.0.1:4010/_x-steady/health" >/dev/null 2>&1
1414
}
1515

1616
kill_server_on_port() {
@@ -25,7 +25,7 @@ function is_overriding_api_base_url() {
2525
[ -n "$TEST_API_BASE_URL" ]
2626
}
2727

28-
if ! is_overriding_api_base_url && ! prism_is_running ; then
28+
if ! is_overriding_api_base_url && ! steady_is_running ; then
2929
# When we exit this script, make sure to kill the background mock server process
3030
trap 'kill_server_on_port 4010' EXIT
3131

@@ -36,19 +36,19 @@ fi
3636
if is_overriding_api_base_url ; then
3737
echo -e "${GREEN}✔ Running tests against ${TEST_API_BASE_URL}${NC}"
3838
echo
39-
elif ! prism_is_running ; then
40-
echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Prism server"
39+
elif ! steady_is_running ; then
40+
echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Steady server"
4141
echo -e "running against your OpenAPI spec."
4242
echo
4343
echo -e "To run the server, pass in the path or url of your OpenAPI"
44-
echo -e "spec to the prism command:"
44+
echo -e "spec to the steady command:"
4545
echo
46-
echo -e " \$ ${YELLOW}npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock path/to/your.openapi.yml${NC}"
46+
echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.19.3 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-query-object-format=dots${NC}"
4747
echo
4848

4949
exit 1
5050
else
51-
echo -e "${GREEN}✔ Mock prism server is running with your OpenAPI spec${NC}"
51+
echo -e "${GREEN}✔ Mock steady server is running with your OpenAPI spec${NC}"
5252
echo
5353
fi
5454

0 commit comments

Comments
 (0)