Skip to content
This repository was archived by the owner on Aug 14, 2025. It is now read-only.

Commit 8d599cd

Browse files
chore(internal): update comment in script
1 parent 5f8ae94 commit 8d599cd

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

scripts/test

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
cd "$(dirname "$0")/.."
6+
7+
RED='\033[0;31m'
8+
GREEN='\033[0;32m'
9+
YELLOW='\033[0;33m'
10+
NC='\033[0m' # No Color
11+
12+
function prism_is_running() {
13+
curl --silent "http://localhost:4010" >/dev/null 2>&1
14+
}
15+
16+
kill_server_on_port() {
17+
pids=$(lsof -t -i tcp:"$1" || echo "")
18+
if [ "$pids" != "" ]; then
19+
kill "$pids"
20+
echo "Stopped $pids."
21+
fi
22+
}
23+
24+
function is_overriding_api_base_url() {
25+
[ -n "$TEST_API_BASE_URL" ]
26+
}
27+
28+
if ! is_overriding_api_base_url && ! prism_is_running ; then
29+
# When we exit this script, make sure to kill the background mock server process
30+
trap 'kill_server_on_port 4010' EXIT
31+
32+
# Start the dev server
33+
./scripts/mock --daemon
34+
fi
35+
36+
if is_overriding_api_base_url ; then
37+
echo -e "${GREEN}✔ Running tests against ${TEST_API_BASE_URL}${NC}"
38+
echo
39+
elif ! prism_is_running ; then
40+
echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Prism server"
41+
echo -e "running against your OpenAPI spec."
42+
echo
43+
echo -e "To run the server, pass in the path or url of your OpenAPI"
44+
echo -e "spec to the prism command:"
45+
echo
46+
echo -e " \$ ${YELLOW}npm exec --package=@stainless-api/[email protected] -- prism mock path/to/your.openapi.yml${NC}"
47+
echo
48+
49+
exit 1
50+
else
51+
echo -e "${GREEN}✔ Mock prism server is running with your OpenAPI spec${NC}"
52+
echo
53+
fi
54+
55+
export DEFER_PYDANTIC_BUILD=false
56+
57+
echo "==> Running tests"
58+
rye run pytest "$@"
59+
60+
echo "==> Running Pydantic v1 tests"
61+
rye run nox -s test-pydantic-v1 -- "$@"

0 commit comments

Comments
 (0)