Skip to content

Commit 6cccdb3

Browse files
committed
fix: set emitter and logger to nil
Since unit tests don't have a real gRPC endpoint, any leftover AppLogEmitter.emitter from a previous spec will raise a GRPC connection error when AppLogEmitter.emit is called, which gets rescued and logged — interfering with specs that assert on logger.error. Resetting AppLogEmitter.emitter and AppLogEmitter.logger to nil after each spec prevents this leak.
1 parent f13aa5d commit 6cccdb3

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

spec/unit/lib/cloud_controller/runner_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ module VCAP::CloudController
3737
allow(Puma::Server).to receive(:new).and_return(puma_server_double)
3838
end
3939

40+
after do
41+
VCAP::AppLogEmitter.emitter = nil
42+
VCAP::AppLogEmitter.logger = nil
43+
end
44+
4045
subject do
4146
Runner.new(argv + ['-c', config_file.path])
4247
end

spec/unit/lib/delayed_job/delayed_worker_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
allow(threaded_worker).to receive(:name=).with(anything)
1818
end
1919

20+
after do
21+
VCAP::AppLogEmitter.emitter = nil
22+
VCAP::AppLogEmitter.logger = nil
23+
end
24+
2025
describe '#initialize' do
2126
it 'sets the correct default queue options' do
2227
worker_instance = CloudController::DelayedWorker.new(options)

0 commit comments

Comments
 (0)