Skip to content

Commit

Permalink
Prevent parallel test failures in request_spec (#3505)
Browse files Browse the repository at this point in the history
I've seen test failures for the 'VCAP::Request.user_guid' context that
seem to be caused by parallel test execution. Thus the tests have been
changed to mimic those in the 'VCAP::Request.current_id' context, i.e.
the 'Steno.config.context' is mocked.
  • Loading branch information
philippthun authored Nov 3, 2023
1 parent eee0ead commit e92ef7b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion spec/unit/lib/vcap/request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,22 @@ module VCAP
end

let(:user_guid) { SecureRandom.uuid }
let(:data) { {} }

before do
allow(Steno.config.context).to receive(:data).and_return(data)
end

it 'sets the new user_guid on the Steno logger context' do
Request.user_guid = user_guid

expect(Steno.config.context.data['user_guid']).to eq user_guid
expect(Steno.config.context.data.fetch('user_guid')).to eq user_guid
end

it 'deletes from the Steno logger context when set to nil' do
Request.user_guid = nil

expect(Steno.config.context.data.key?('user_guid')).to be false
end
end
end
Expand Down

0 comments on commit e92ef7b

Please sign in to comment.