Skip to content

Commit

Permalink
test: what happens if longest without a report is false
Browse files Browse the repository at this point in the history
  • Loading branch information
gastonfournier committed Dec 10, 2024
1 parent 59bc154 commit 2946ca7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
Empty file added lib/unleash/feature_toggle.rb
Empty file.
2 changes: 1 addition & 1 deletion lib/unleash/metrics_reporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def post
Unleash.logger.debug "post() Report"

bucket = self.generate_report
if bucket.nil? && (Time.now - self.last_time < LONGEST_WITHOUT_A_REPORT) # and last time is less then 10 minutes...
if bucket.nil? && (false && Time.now - self.last_time < LONGEST_WITHOUT_A_REPORT) # and last time is less then 10 minutes...
Unleash.logger.debug "Report not posted to server, as it would have been empty. (and has been empty for up to 10 min)"

return
Expand Down
13 changes: 13 additions & 0 deletions spec/unleash/metrics_reporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,19 @@
)
end

it "generates the correct report with no metrics" do
Unleash.configure do |config|
config.url = 'http://test-url/'
config.app_name = 'my-test-app'
config.instance_id = 'rspec/test'
config.disable_client = true
end
Unleash.engine = YggdrasilEngine.new

report = metrics_reporter.generate_report
expect(report).to be_nil
end

it "sends the correct report" do
WebMock.stub_request(:post, "http://test-url/client/metrics")
.with(
Expand Down

0 comments on commit 2946ca7

Please sign in to comment.