|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +# |
| 4 | +# Copyright 2019, Optimizely and contributors |
| 5 | +# |
| 6 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | +# you may not use this file except in compliance with the License. |
| 8 | +# You may obtain a copy of the License at |
| 9 | +# |
| 10 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +# |
| 12 | +# Unless required by applicable law or agreed to in writing, software |
| 13 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | +# See the License for the specific language governing permissions and |
| 16 | +# limitations under the License. |
| 17 | +# |
| 18 | +require 'spec_helper' |
| 19 | +require 'optimizely/config_manager/async_scheduler' |
| 20 | +require 'optimizely/logger' |
| 21 | + |
| 22 | +describe Optimizely::AsyncScheduler do |
| 23 | + it 'should log error trace when callback fails to execute' do |
| 24 | + def some_callback(_args); end |
| 25 | + |
| 26 | + spy_logger = spy('logger') |
| 27 | + |
| 28 | + scheduler = Optimizely::AsyncScheduler.new(method(:some_callback), 10, false, spy_logger) |
| 29 | + scheduler.start! |
| 30 | + |
| 31 | + while scheduler.running; end |
| 32 | + expect(spy_logger).to have_received(:log).with( |
| 33 | + Logger::ERROR, |
| 34 | + 'Something went wrong when executing passed callback. wrong number of arguments (given 0, expected 1)' |
| 35 | + ) |
| 36 | + end |
| 37 | +end |
0 commit comments