Skip to content

Commit e92ef7b

Browse files
authored
Prevent parallel test failures in request_spec (#3505)
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.
1 parent eee0ead commit e92ef7b

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

spec/unit/lib/vcap/request_spec.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,22 @@ module VCAP
113113
end
114114

115115
let(:user_guid) { SecureRandom.uuid }
116+
let(:data) { {} }
117+
118+
before do
119+
allow(Steno.config.context).to receive(:data).and_return(data)
120+
end
116121

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

120-
expect(Steno.config.context.data['user_guid']).to eq user_guid
125+
expect(Steno.config.context.data.fetch('user_guid')).to eq user_guid
126+
end
127+
128+
it 'deletes from the Steno logger context when set to nil' do
129+
Request.user_guid = nil
130+
131+
expect(Steno.config.context.data.key?('user_guid')).to be false
121132
end
122133
end
123134
end

0 commit comments

Comments
 (0)