test/plugin/test_out_indicative.rb in fluent-plugin-indicative-0.1.6 vs test/plugin/test_out_indicative.rb in fluent-plugin-indicative-0.1.7
- old
+ new
@@ -75,6 +75,58 @@
end
events = d.events
assert_equal 0, events.length
assert_requested :post, d.instance.api_url, times: 1
end
+
+ def test_array_transformation
+ d = create_driver(STREAM_CONFIG)
+ stub_request(:any, d.instance.api_url)
+ d.run(default_tag: 'test') do
+ d.feed({'event_name' => 'screen_view', 'created_at' => '2015-01-01T10:00:00.000Z', 'session_id' => 'a3bd2', 'experiments': ['a', 'c']})
+ end
+ events = d.events
+ assert_equal 0, events.length
+ assert_requested :post, d.instance.api_url,
+ headers: {'Content-Type' => 'application/json'}, body: {
+ 'apiKey' => 'INDICATIVE_API_KEY',
+ 'events' => [{
+ 'eventName' => 'screen_view',
+ 'eventUniqueId' => 'a3bd2',
+ 'properties' => {
+ 'event_name' => 'screen_view',
+ 'created_at' => '2015-01-01T10:00:00.000Z',
+ 'session_id' => 'a3bd2',
+ 'experiments.a' => true,
+ 'experiments.c' => true
+ },
+ 'eventTime' => '2015-01-01T10:00:00+00:00'
+ }]
+ }.to_json, times: 1
+ end
+
+ def test_key_value_object_transformation
+ d = create_driver(STREAM_CONFIG)
+ stub_request(:any, d.instance.api_url)
+ d.run(default_tag: 'test') do
+ d.feed({'event_name' => 'screen_view', 'created_at' => '2015-01-01T10:00:00.000Z', 'session_id' => 'a3bd2', 'experiments': [{'key': 'a', 'value': 1}, {'key': 'b', 'value': 2}]})
+ end
+ events = d.events
+ assert_equal 0, events.length
+ assert_requested :post, d.instance.api_url,
+ headers: {'Content-Type' => 'application/json'}, body: {
+ 'apiKey' => 'INDICATIVE_API_KEY',
+ 'events' => [{
+ 'eventName' => 'screen_view',
+ 'eventUniqueId' => 'a3bd2',
+ 'properties' => {
+ 'event_name' => 'screen_view',
+ 'created_at' => '2015-01-01T10:00:00.000Z',
+ 'session_id' => 'a3bd2',
+ 'experiments.a' => 1,
+ 'experiments.b' => 2
+ },
+ 'eventTime' => '2015-01-01T10:00:00+00:00'
+ }]
+ }.to_json, times: 1
+ end
end