Skip to content

Commit

Permalink
in_http: Add a test case for the keep_time_key flag.
Browse files Browse the repository at this point in the history
This patch adds a test case (test_multi_json_with_keep_time_key) to
test_in_http.rb.

I've confirmed it passes without problems in my testing machine:

    test_multi_json_with_keep_time_key:            .: (0.606005)

Signed-off-by: Fujimoto Seiji <fujimoto@clear-code.com>
  • Loading branch information
Fujimoto Seiji committed Jun 19, 2018
1 parent 39f3a0d commit d0809c6
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/plugin/test_in_http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,34 @@ def test_json_with_add_http_headers
assert include_http_header?(d.events[1][2])
end

def test_multi_json_with_keep_time_key
d = create_driver(CONFIG + %[
<parse>
@type json
keep_time_key true
</parse>
])
time1 = event_time("2011-01-02 13:14:15 UTC")
time2 = event_time("2012-01-02 13:14:15 UTC")
records = [{"time"=>time1.to_i},{"time"=>time2.to_i}]
tag = "tag1"
res_codes = []

d.run(expect_records: 2, timeout: 5) do
res = post("/#{tag}", records.to_json, {"Content-Type"=>"application/octet-stream"})
res_codes << res.code
end
assert_equal ["200"], res_codes

assert_equal "tag1", d.events[0][0]
assert_equal_event_time time1, d.events[0][1]
assert_equal d.events[0][2], records[0]

assert_equal "tag1", d.events[1][0]
assert_equal_event_time time2, d.events[1][1]
assert_equal d.events[1][2], records[1]
end

def test_application_json
d = create_driver
time = event_time("2011-01-02 13:14:15 UTC")
Expand Down

0 comments on commit d0809c6

Please sign in to comment.