File: fix-riemann-test.patch

package info (click to toggle)
ruby-metriks 0.9.9.8-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 308 kB
  • sloc: ruby: 1,855; makefile: 2
file content (86 lines) | stat: -rw-r--r-- 2,802 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
Description: test: make RiemannReporterTest robust
 The test suite was using strict Mocha expectations on the exact hash
 passed to Riemann::Client#<<. However since riemann-client 1.2.x, the
 arguments received by the mock are affected by internal normalisation.
Author: Simon Quigley <tsimonq2@debian.org>
Origin: vendor
Last-Update: 2026-02-19
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/test/riemann_reporter_test.rb
+++ b/test/riemann_reporter_test.rb
@@ -38,51 +38,30 @@ class RiemannReporterTest < Test::Unit::
     @registry.utilization_timer('utilization_timer.testing').update(1.5)
     @registry.gauge('gauge.testing') { 123 }
 
-    @reporter.client.expects(:<<).at_least_once
-    @reporter.client.expects(:<<).with(
-      :host => "h",
-      :service => "meter.testing count",
-      :metric => 1,
-      :tags => ["meter"],
-      :ttl => 90
-    )
-    @reporter.client.expects(:<<).with(
-      :host => "h",
-      :service => "counter.testing count",
-      :metric => 1,
-      :tags => ["counter"],
-      :ttl => 90
-    )
-    @reporter.client.expects(:<<).with(
-      :host => "h",
-      :service => "timer.testing max",
-      :metric => 1.5,
-      :tags => ["timer"],
-      :ttl => 90
-    )
-    @reporter.client.expects(:<<).with(
-      :host => "h",
-      :service => "histogram.testing max",
-      :metric => 1.5,
-      :tags => ["histogram"],
-      :ttl => 90
-    )
-    @reporter.client.expects(:<<).with(
-      :host => "h",
-      :service => "utilization_timer.testing mean",
-      :metric => 1.5,
-      :tags => ["utilization_timer"],
-      :ttl => 90
-    )
-
-    @reporter.client.expects(:<<).with(
-      :host => "h",
-      :service => "gauge.testing value",
-      :metric => 123,
-      :tags => ["gauge"],
-      :ttl => 90
-    )
+    events = []
+    @reporter.client.stubs(:<<).with do |event|
+      events << (event.is_a?(Hash) ? event.dup : event.to_h rescue event)
+      true
+    end
 
     @reporter.write
+
+    assert_event(events, "meter.testing count",          1,   ["meter"])
+    assert_event(events, "counter.testing count",        1,   ["counter"])
+    assert_event(events, "timer.testing max",            1.5, ["timer"])
+    assert_event(events, "histogram.testing max",        1.5, ["histogram"])
+    assert_event(events, "utilization_timer.testing mean", 1.5, ["utilization_timer"])
+    assert_event(events, "gauge.testing value",          123, ["gauge"])
+  end
+
+  def assert_event(events, service, metric, tags)
+    found = events.any? do |e|
+      e[:host] == "h" &&
+      e[:service] == service &&
+      e[:metric] == metric &&
+      e[:tags] == tags &&
+      e[:ttl] == 90
+    end
+    assert found, "Missing expected Riemann event: #{service} = #{metric}"
   end
 end