Skip to content

Commit e626d75

Browse files
committed
test: Start mock python server after Obelisk
1 parent 867dc17 commit e626d75

2 files changed

Lines changed: 10 additions & 11 deletions

File tree

.envrc-example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ watch_file ./rust-toolchain.toml ./flake.nix
44
export GITHUB_TOKEN="..."
55
export GITHUB_WEBHOOK_SECRET="..."
66
export OPENAI_API_KEY="..."
7+
export OPENAI_API_BASE_URL="https://api.openai.com"
78
export TURSO_TOKEN="..."
89
export TURSO_LOCATION="[yourdb].turso.io"
910

scripts/test-e2e.sh

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,15 @@ export GITHUB_WEBHOOK_SECRET="It's a Secret to Everybody"
2222
# Use mock server unless OPENAI_API_KEY is already set
2323
if [[ -z "${OPENAI_API_KEY:-}" ]]; then
2424
echo "OPENAI_API_KEY not set, using mock OpenAI server"
25-
25+
export OPENAI_API_KEY="mock-api-key-for-testing"
26+
export OPENAI_API_BASE_URL="http://127.0.0.1:$MOCK_OPENAI_PORT"
27+
fi
28+
29+
obelisk server verify --config $OBELISK_TOML
30+
obelisk server run --config $OBELISK_TOML &
31+
PID=$!
32+
# Use mock server unless OPENAI_API_KEY is already set
33+
if [[ -z "${OPENAI_API_KEY:-}" ]]; then
2634
# Start mock OpenAI server
2735
python3 ./scripts/mock-openai-server.py $MOCK_OPENAI_PORT &
2836
MOCK_PID=$!
@@ -38,18 +46,8 @@ if [[ -z "${OPENAI_API_KEY:-}" ]]; then
3846
sleep 0.5
3947
done
4048
echo "Mock OpenAI server is ready"
41-
42-
# Set environment variables for mock OpenAI
43-
export OPENAI_API_KEY="mock-api-key-for-testing"
44-
export OPENAI_API_BASE_URL="http://127.0.0.1:$MOCK_OPENAI_PORT"
45-
else
46-
echo "OPENAI_API_KEY is set, using real OpenAI API"
47-
# OPENAI_API_BASE_URL can optionally be set for custom endpoints
4849
fi
4950

50-
obelisk server verify --config $OBELISK_TOML
51-
obelisk server run --config $OBELISK_TOML &
52-
PID=$!
5351
cleanup() {
5452
echo "Sending SIGINT to obelisk process $PID..."
5553
kill -SIGINT $PID 2>/dev/null || true

0 commit comments

Comments
 (0)