Skip to content

Commit

Permalink
fixed failing test case
Browse files Browse the repository at this point in the history
  • Loading branch information
jayamala17 committed May 2, 2024
1 parent f38809c commit b714749
Showing 1 changed file with 8 additions and 29 deletions.
37 changes: 8 additions & 29 deletions test/test_jobs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,40 +27,19 @@ def test_gateway
end

def test_push_last_successful_run
time_now = (Time.now.to_i) * 1000 # milli sec
@gauge.expect(:set, nil, [time_now])
@registry.expect(:register, nil, [@gauge])
@gateway.expect(:add, nil, [@registry])

Prometheus::Client::Gauge.stub(:new, @gauge) do
@metrics.stub(:registry, @registry) do
@metrics.stub(:gateway, @gateway) do
@metrics.push_last_successful_run

end
end
time_now = (Time.now.to_i)
Time.stub :now, time_now do
@metrics.push_last_successful_run
end
assert_mock @gauge
assert_mock @registry
assert_mock @gateway
expected_value = time_now * 1000 #millisec
assert_equal expected_value,@metrics.send(:registry).get(:dark_blue_last_successful_run).get
end

def test_push_processing_duration
expected_duration = 5
@gauge.expect(:set, nil, [expected_duration])
@registry.expect(:register, nil, [@gauge])
@gateway.expect(:add, nil, [@registry])

Prometheus::Client::Gauge.stub(:new, @gauge) do
@metrics.stub(:registry, @registry) do
@metrics.stub(:gateway, @gateway) do
@metrics.push_processing_duration(Time.now,(Time.now + expected_duration))
end
end
end
assert_mock @gauge
assert_mock @registry
assert_mock @gateway
time_now = Time.now
@metrics.push_processing_duration(time_now,(time_now + expected_duration))
assert_equal expected_duration, @metrics.send(:registry).get(:dark_blue_processing_duration).get
end
# TBD:

Expand Down

0 comments on commit b714749

Please sign in to comment.