From 2946ca7da367e2a19b44acad148a49d505095639 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gast=C3=B3n=20Fournier?= Date: Tue, 10 Dec 2024 11:12:08 +0100 Subject: [PATCH] test: what happens if longest without a report is false --- lib/unleash/feature_toggle.rb | 0 lib/unleash/metrics_reporter.rb | 2 +- spec/unleash/metrics_reporter_spec.rb | 13 +++++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 lib/unleash/feature_toggle.rb diff --git a/lib/unleash/feature_toggle.rb b/lib/unleash/feature_toggle.rb new file mode 100644 index 00000000..e69de29b diff --git a/lib/unleash/metrics_reporter.rb b/lib/unleash/metrics_reporter.rb index d9f9f337..e3d41ed3 100755 --- a/lib/unleash/metrics_reporter.rb +++ b/lib/unleash/metrics_reporter.rb @@ -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 diff --git a/spec/unleash/metrics_reporter_spec.rb b/spec/unleash/metrics_reporter_spec.rb index 2a0e765b..fe39a70e 100644 --- a/spec/unleash/metrics_reporter_spec.rb +++ b/spec/unleash/metrics_reporter_spec.rb @@ -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(