Skip to content

Commit

Permalink
Merge pull request #1102 from cosmo0920/reduce-test-execution-time-in…
Browse files Browse the repository at this point in the history
…_exec

Use new test driver syntax in_exec test cases
  • Loading branch information
tagomoris authored Jul 28, 2016
2 parents 9d0a8dc + ac272e1 commit 82eaf4a
Showing 1 changed file with 25 additions and 29 deletions.
54 changes: 25 additions & 29 deletions test/plugin/test_in_exec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,52 +86,48 @@ def test_configure_with_regexp
def test_emit
d = create_driver

d.run do
sleep 2
end

emits = d.events
assert_equal true, emits.length > 0
assert_equal ["tag1", @test_time, {"k1"=>"ok"}], emits[0]
assert_equal_event_time(@test_time, emits[0][1])
d.run(expect_emits: 2)

assert_equal true, d.events.length > 0
d.events.each_with_index {|event, i|
assert_equal ["tag1", @test_time, {"k1"=>"ok"}], event
assert_equal_event_time(@test_time, event[1])
}
end

def test_emit_json
d = create_driver json_config

d.run do
sleep 2
end
d.run(expect_emits: 2)

emits = d.events
assert_equal true, emits.length > 0
assert_equal ["tag1", @test_time, {"k1"=>"ok"}], emits[0]
assert_equal_event_time(@test_time, emits[0][1])
assert_equal true, d.events.length > 0
d.events.each_with_index {|event, i|
assert_equal ["tag1", @test_time, {"k1"=>"ok"}], event
assert_equal_event_time(@test_time, event[1])
}
end

def test_emit_msgpack
d = create_driver msgpack_config

d.run do
sleep 2
end
d.run(expect_emits: 2)

emits = d.events
assert_equal true, emits.length > 0
assert_equal ["tag1", @test_time, {"k1"=>"ok"}], emits[0]
assert_equal_event_time(@test_time, emits[0][1])
assert_equal true, d.events.length > 0
d.events.each_with_index {|event, i|
assert_equal ["tag1", @test_time, {"k1"=>"ok"}], event
assert_equal_event_time(@test_time, event[1])
}
end

def test_emit_regexp
d = create_driver regexp_config

d.run do
sleep 2
end
d.run(expect_emits: 2)

emits = d.events
assert_equal true, emits.length > 0
assert_equal ["regex_tag", @test_time, {"message"=>"hello"}], emits[0]
assert_equal_event_time(@test_time, emits[0][1])
assert_equal true, d.events.length > 0
d.events.each_with_index {|event, i|
assert_equal ["regex_tag", @test_time, {"message"=>"hello"}], event
assert_equal_event_time(@test_time, event[1])
}
end
end

0 comments on commit 82eaf4a

Please sign in to comment.