Permalink
Browse files

Dirty tracking to the rescue

  • Loading branch information...
1 parent 0ca998e commit 613141a247d3dfa6274507c59b854ac01e702f23 @paukul committed Nov 15, 2010
Showing with 19 additions and 0 deletions.
  1. +4 −0 lib/amqp_logging/metrics_agent.rb
  2. +15 −0 test/metrics_agent_test.rb
@@ -65,6 +65,10 @@ class << self
logger
end
+ def dirty?
+ @fields != @default_fields
+ end
+
private
def self.flush_all_instances
@@instances.each {|i| i.flush }
View
@@ -34,6 +34,21 @@ def setup
@agent.flush
assert_equal nil, @agent[:foo]
end
+
+ test "should keep track if the agents data is dirty" do
+ assert !@agent.dirty?
+
+ @agent[:foo] = :bar
+ assert @agent.dirty?
+ end
+
+ test "flushing should reset dirty status" do
+ @agent[:foo] = :bar
+ assert @agent.dirty?
+
+ @agent.flush
+ assert !@agent.dirty?
+ end
end
class LoggingProxyTest < Test::Unit::TestCase

0 comments on commit 613141a

Please sign in to comment.