Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions test/braintrust/state_login_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,9 @@ def test_login_with_invalid_api_key
end

def test_login_in_thread_retries_on_failure
state = Braintrust::State.new(
api_key: @api_key,
app_url: "https://www.braintrust.dev"
)

# Disable VCR to allow WebMock stubs to work properly
# IMPORTANT: Disable VCR and set up stubs BEFORE creating State, because
# State.new immediately spawns a background login thread when no org_id
# is provided. If stubs aren't ready, the thread hits WebMock errors.
VCR.turn_off!
begin
# Stub HTTP to fail twice, then succeed
Expand All @@ -71,8 +68,12 @@ def test_login_in_thread_retries_on_failure
)

begin
# Start background login
state.login_in_thread
# Now create State - this spawns the login thread with stubs already in place
state = Braintrust::State.new(
api_key: @api_key,
app_url: "https://www.braintrust.dev",
enable_tracing: false
)

# Wait for it to complete (should retry and eventually succeed)
state.wait_for_login(5)
Expand Down