test/plugin/test_out_mackerel.rb in fluent-plugin-mackerel-0.0.1 vs test/plugin/test_out_mackerel.rb in fluent-plugin-mackerel-0.0.2
- old
+ new
@@ -19,10 +19,19 @@
api_key 123456
metrics_prefix service
out_keys val1,val2,val3
]
+ CONFIG_SMALL_FLUSH_INTERVAL = %[
+ type mackerel
+ api_key 123456
+ hostid xyz
+ metrics_prefix service
+ out_keys val1,val2,val3
+ flush_interval 1s
+ ]
+
def create_driver(conf = CONFIG, tag='test')
Fluent::Test::BufferedOutputTestDriver.new(Fluent::MackerelOutput, tag).configure(conf)
end
def test_configure
@@ -33,15 +42,19 @@
assert_raise(Fluent::ConfigError) {
d = create_driver(CONFIG_NOHOST)
}
+ d = create_driver(CONFIG_SMALL_FLUSH_INTERVAL)
+ assert_equal d.instance.instance_variable_get(:@flush_interval), 60
+
d = create_driver()
assert_equal d.instance.instance_variable_get(:@api_key), '123456'
assert_equal d.instance.instance_variable_get(:@hostid), 'xyz'
assert_equal d.instance.instance_variable_get(:@metrics_prefix), 'service'
assert_equal d.instance.instance_variable_get(:@out_keys), ['val1','val2','val3']
+ assert_equal d.instance.instance_variable_get(:@flush_interval), 60
end
def test_write
d = create_driver()
stub(d.instance.mackerel).post_metrics([
@@ -58,7 +71,15 @@
d.emit({'val1' => 1, 'val2' => 2, 'val3' => 3, 'val4' => 4}, t)
d.emit({'val1' => 5, 'val2' => 6, 'val3' => 7, 'val4' => 8}, t)
d.run()
end
+ def test_wait_for_minute
+ d = create_driver()
+ mackerel = d.instance.mackerel
+ assert_equal mackerel.wait_for_minute, false
+ assert_equal mackerel.wait_for_minute, true
+ sleep 60
+ assert_equal mackerel.wait_for_minute, false
+ end
end
\ No newline at end of file