|
323 | 323 | end |
324 | 324 | end |
325 | 325 | end |
| 326 | + |
| 327 | + describe '#streaming_enabled?' do |
| 328 | + context 'when server_monitoring_mode is :stream' do |
| 329 | + let(:monitor_options) do |
| 330 | + { server_monitoring_mode: :stream } |
| 331 | + end |
| 332 | + |
| 333 | + it 'returns true' do |
| 334 | + expect(monitor.send(:streaming_enabled?)).to be true |
| 335 | + end |
| 336 | + end |
| 337 | + |
| 338 | + context 'when server_monitoring_mode is :poll' do |
| 339 | + let(:monitor_options) do |
| 340 | + { server_monitoring_mode: :poll } |
| 341 | + end |
| 342 | + |
| 343 | + it 'returns false' do |
| 344 | + expect(monitor.send(:streaming_enabled?)).to be false |
| 345 | + end |
| 346 | + end |
| 347 | + |
| 348 | + context 'when server_monitoring_mode is :auto' do |
| 349 | + let(:monitor_options) do |
| 350 | + { server_monitoring_mode: :auto } |
| 351 | + end |
| 352 | + |
| 353 | + context 'when not in a FaaS environment' do |
| 354 | + local_env( |
| 355 | + 'AWS_EXECUTION_ENV' => nil, |
| 356 | + 'AWS_LAMBDA_RUNTIME_API' => nil, |
| 357 | + 'FUNCTIONS_WORKER_RUNTIME' => nil, |
| 358 | + 'K_SERVICE' => nil, |
| 359 | + 'FUNCTION_NAME' => nil, |
| 360 | + 'VERCEL' => nil, |
| 361 | + ) |
| 362 | + |
| 363 | + it 'returns true' do |
| 364 | + expect(monitor.send(:streaming_enabled?)).to be true |
| 365 | + end |
| 366 | + end |
| 367 | + |
| 368 | + context 'when in a FaaS environment' do |
| 369 | + local_env('FUNCTIONS_WORKER_RUNTIME' => 'ruby') |
| 370 | + |
| 371 | + it 'returns false' do |
| 372 | + expect(monitor.send(:streaming_enabled?)).to be false |
| 373 | + end |
| 374 | + end |
| 375 | + end |
| 376 | + |
| 377 | + context 'when server_monitoring_mode is not set' do |
| 378 | + let(:monitor_options) do |
| 379 | + {} |
| 380 | + end |
| 381 | + |
| 382 | + context 'when not in a FaaS environment' do |
| 383 | + local_env( |
| 384 | + 'AWS_EXECUTION_ENV' => nil, |
| 385 | + 'AWS_LAMBDA_RUNTIME_API' => nil, |
| 386 | + 'FUNCTIONS_WORKER_RUNTIME' => nil, |
| 387 | + 'K_SERVICE' => nil, |
| 388 | + 'FUNCTION_NAME' => nil, |
| 389 | + 'VERCEL' => nil, |
| 390 | + ) |
| 391 | + |
| 392 | + it 'defaults to auto and returns true' do |
| 393 | + expect(monitor.send(:streaming_enabled?)).to be true |
| 394 | + end |
| 395 | + end |
| 396 | + |
| 397 | + context 'when in a FaaS environment' do |
| 398 | + local_env('FUNCTIONS_WORKER_RUNTIME' => 'ruby') |
| 399 | + |
| 400 | + it 'defaults to auto and returns false' do |
| 401 | + expect(monitor.send(:streaming_enabled?)).to be false |
| 402 | + end |
| 403 | + end |
| 404 | + end |
| 405 | + end |
326 | 406 | end |
0 commit comments