forked from fluent/fluentd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test driver: Return the return value of yield
Fix fluent#1268
- Loading branch information
Showing
7 changed files
with
148 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
require_relative '../helper' | ||
require 'fluent/test/driver/filter' | ||
|
||
class NullFilter < Fluent::Plugin::Filter | ||
def filter(tag, time, record) | ||
end | ||
end | ||
|
||
class TestDriverFilterTest < Test::Unit::TestCase | ||
def setup | ||
Fluent::Test.setup | ||
end | ||
|
||
def create_driver(conf = "") | ||
Fluent::Test::Driver::Filter.new(NullFilter).configure(conf) | ||
end | ||
|
||
test 'run w/ block returns last evaluated value in block' do | ||
d = create_driver | ||
value = d.run do | ||
:value | ||
end | ||
assert_equal(value, :value) | ||
end | ||
|
||
test 'run w/o block returns nil' do | ||
d = create_driver | ||
assert_nil(d.run(timeout: 0.01)) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
require_relative '../helper' | ||
require 'fluent/test/driver/formatter' | ||
|
||
class NullFormatter < Fluent::Plugin::Formatter | ||
def format(tag, time, record) | ||
end | ||
end | ||
|
||
class TestDriverFormatterTest < Test::Unit::TestCase | ||
def setup | ||
Fluent::Test.setup | ||
end | ||
|
||
def create_driver(conf = "") | ||
Fluent::Test::Driver::Formatter.new(NullFormatter).configure(conf) | ||
end | ||
|
||
test 'run w/ block returns last evaluated value in block' do | ||
d = create_driver | ||
value = d.run do | ||
:value | ||
end | ||
assert_equal(value, :value) | ||
end | ||
|
||
test 'run w/o block returns nil' do | ||
d = create_driver | ||
assert_nil(d.run(timeout: 0.01)) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
require_relative '../helper' | ||
require 'fluent/test/driver/input' | ||
|
||
class NullInput < Fluent::Plugin::Input | ||
end | ||
|
||
class TestDriverInputTest < Test::Unit::TestCase | ||
def setup | ||
Fluent::Test.setup | ||
end | ||
|
||
def create_driver(conf = "") | ||
Fluent::Test::Driver::Input.new(NullInput).configure(conf) | ||
end | ||
|
||
test 'run w/ block returns last evaluated value in block' do | ||
d = create_driver | ||
value = d.run do | ||
:value | ||
end | ||
assert_equal(value, :value) | ||
end | ||
|
||
test 'run w/o block returns nil' do | ||
d = create_driver | ||
assert_nil(d.run(timeout: 0.01)) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
require_relative '../helper' | ||
require 'fluent/test/driver/output' | ||
require 'fluent/plugin/out_null' | ||
|
||
class TestDriverOutputTest < Test::Unit::TestCase | ||
def setup | ||
Fluent::Test.setup | ||
end | ||
|
||
def create_driver(conf = "") | ||
Fluent::Test::Driver::Output.new(Fluent::Plugin::NullOutput).configure(conf) | ||
end | ||
|
||
test 'run w/ block returns last evaluated value in block' do | ||
d = create_driver | ||
value = d.run do | ||
:value | ||
end | ||
assert_equal(value, :value) | ||
end | ||
|
||
test 'run w/o block returns nil' do | ||
d = create_driver | ||
assert_nil(d.run(timeout: 0.01)) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
require_relative '../helper' | ||
require 'fluent/test/driver/parser' | ||
|
||
class NullParser < Fluent::Plugin::Parser | ||
def parse(text) | ||
yield nil, nil | ||
end | ||
end | ||
|
||
class TestDriverParserTest < Test::Unit::TestCase | ||
def setup | ||
Fluent::Test.setup | ||
end | ||
|
||
def create_driver(conf = "") | ||
Fluent::Test::Driver::Parser.new(NullParser).configure(conf) | ||
end | ||
|
||
test 'run w/ block returns last evaluated value in block' do | ||
d = create_driver | ||
value = d.run do | ||
:value | ||
end | ||
assert_equal(value, :value) | ||
end | ||
|
||
test 'run w/o block returns nil' do | ||
d = create_driver | ||
assert_nil(d.run(timeout: 0.01)) | ||
end | ||
end |