|
7 | 7 | subject { SplitIoClient::Engine::PushManager } |
8 | 8 |
|
9 | 9 | let(:body_response) { File.read(File.join(SplitIoClient.root, 'spec/test_data/integrations/auth_body_response.json')) } |
10 | | - let(:api_key) { 'api-key-test' } |
| 10 | + let(:api_key) { 'PushManager-key' } |
11 | 11 | let(:log) { StringIO.new } |
12 | 12 | let(:config) { SplitIoClient::SplitConfig.new(logger: Logger.new(log)) } |
13 | 13 | let(:splits_repository) { SplitIoClient::Cache::Repositories::SplitsRepository.new(config) } |
|
17 | 17 | let(:segment_fetcher) { SplitIoClient::Cache::Fetchers::SegmentFetcher.new(segments_repository, api_key, config, runtime_producer) } |
18 | 18 | let(:splits_worker) { SplitIoClient::SSE::Workers::SplitsWorker.new(split_fetcher, config, splits_repository) } |
19 | 19 | let(:segments_worker) { SplitIoClient::SSE::Workers::SegmentsWorker.new(segment_fetcher, config, segments_repository) } |
20 | | - let(:notification_manager_keeper) { SplitIoClient::SSE::NotificationManagerKeeper.new(config, runtime_producer) } |
| 20 | + let(:push_status_queue) { Queue.new } |
| 21 | + let(:notification_manager_keeper) { SplitIoClient::SSE::NotificationManagerKeeper.new(config, runtime_producer, push_status_queue) } |
21 | 22 | let(:repositories) { { splits: splits_repository, segments: segments_repository } } |
22 | 23 | let(:impression_counter) { SplitIoClient::Engine::Common::ImpressionCounter.new } |
23 | 24 | let(:params) do |
|
30 | 31 | end |
31 | 32 | let(:synchronizer) { SplitIoClient::Engine::Synchronizer.new(repositories, api_key, config, params) } |
32 | 33 | let(:event_parser) { SplitIoClient::SSE::EventSource::EventParser.new(config) } |
33 | | - let(:push_status_queue) { Queue.new } |
34 | | - let(:sse_client) { SplitIoClient::SSE::EventSource::Client.new(config, api_key, telemetry_runtime_producer, event_parser, notification_manager_keeper, notification_processor, push_status_queue) } |
| 34 | + let(:notification_processor) { SplitIoClient::SSE::NotificationProcessor.new(config, splits_worker, segments_worker) } |
| 35 | + let(:sse_client) { SplitIoClient::SSE::EventSource::Client.new(config, api_key, runtime_producer, event_parser, notification_manager_keeper, notification_processor, push_status_queue) } |
35 | 36 |
|
36 | 37 | context 'start_sse' do |
37 | 38 | it 'must connect to server' do |
|
43 | 44 | stub_request(:get, config.auth_service_url).to_return(status: 200, body: body_response) |
44 | 45 | config.streaming_service_url = server.base_uri |
45 | 46 |
|
46 | | - action_event = nil |
47 | 47 | sse_handler = SplitIoClient::SSE::SSEHandler.new(config, splits_worker, segments_worker, sse_client) |
48 | 48 |
|
49 | 49 | push_manager = subject.new(config, sse_handler, api_key, runtime_producer) |
|
54 | 54 | sleep(1.5) |
55 | 55 | expect(connected).to eq(true) |
56 | 56 | expect(sse_handler.connected?).to eq(true) |
57 | | - expect(action_event).to eq(SplitIoClient::Constants::PUSH_CONNECTED) |
| 57 | + expect(push_status_queue.pop(true)).to eq(SplitIoClient::Constants::PUSH_CONNECTED) |
58 | 58 | end |
59 | 59 | end |
60 | 60 |
|
|
101 | 101 | stub_request(:get, config.auth_service_url).to_return(status: 200, body: body_response) |
102 | 102 | config.streaming_service_url = server.base_uri |
103 | 103 |
|
104 | | - action_event = nil |
105 | 104 | sse_handler = SplitIoClient::SSE::SSEHandler.new(config, splits_worker, segments_worker, sse_client) |
106 | | - |
107 | 105 | push_manager = subject.new(config, sse_handler, api_key, runtime_producer) |
108 | 106 | connected = push_manager.start_sse |
109 | 107 |
|
|
113 | 111 |
|
114 | 112 | expect(connected).to eq(true) |
115 | 113 | expect(sse_handler.connected?).to eq(true) |
116 | | - expect(action_event).to eq(SplitIoClient::Constants::PUSH_CONNECTED) |
| 114 | + expect(push_status_queue.pop(true)).to eq(SplitIoClient::Constants::PUSH_CONNECTED) |
117 | 115 |
|
118 | 116 | push_manager.stop_sse |
119 | 117 |
|
|
0 commit comments