Skip to content

Commit 66b9615

Browse files
stainless-app[bot]batuhan
authored andcommitted
refactor(tests): switch from prism to steady
1 parent 8655f9f commit 66b9615

2 files changed

Lines changed: 21 additions & 21 deletions

File tree

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=repeat --validator-query-object-format=brackets "$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=repeat --validator-query-object-format=brackets "$URL"
5252
fi

scripts/test

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

15-
function prism_is_running() {
16-
curl --silent "http://localhost:4010" >/dev/null 2>&1
15+
function steady_is_running() {
16+
curl --silent "http://127.0.0.1:4010/_x-steady/health" >/dev/null 2>&1
1717
}
1818

1919
kill_server_on_port() {
@@ -28,7 +28,7 @@ function is_overriding_api_base_url() {
2828
[ -n "${TEST_API_BASE_URL:-}" ]
2929
}
3030

31-
if ! is_overriding_api_base_url && ! prism_is_running ; then
31+
if ! is_overriding_api_base_url && ! steady_is_running ; then
3232
# When we exit this script, make sure to kill the background mock server process
3333
trap 'kill_server_on_port 4010' EXIT
3434

@@ -39,19 +39,19 @@ fi
3939
if is_overriding_api_base_url ; then
4040
echo -e "${GREEN}✔ Running tests against ${TEST_API_BASE_URL}${NC}"
4141
echo
42-
elif ! prism_is_running ; then
43-
echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Prism server"
42+
elif ! steady_is_running ; then
43+
echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Steady server"
4444
echo -e "running against your OpenAPI spec."
4545
echo
4646
echo -e "To run the server, pass in the path or url of your OpenAPI"
47-
echo -e "spec to the prism command:"
47+
echo -e "spec to the steady command:"
4848
echo
49-
echo -e " \$ ${YELLOW}npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock path/to/your.openapi.yml${NC}"
49+
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=repeat --validator-query-object-format=brackets${NC}"
5050
echo
5151

5252
exit 1
5353
else
54-
echo -e "${GREEN}✔ Mock prism server is running with your OpenAPI spec${NC}"
54+
echo -e "${GREEN}✔ Mock steady server is running with your OpenAPI spec${NC}"
5555
echo
5656
fi
5757

0 commit comments

Comments
 (0)