spec/out_split_spec.rb in fluent-plugin-split-0.0.2 vs spec/out_split_spec.rb in fluent-plugin-split-0.0.3
- old
+ new
@@ -1,15 +1,74 @@
# encoding: UTF-8
-require_relative 'spec_helper'
+require 'spec_helper'
-describe Fluent::SplitOutput do
- before { Fluent::Test.setup }
- CONFIG = %[
- type split
- output_tag split.keyword
- output_key keyword
- format csv
- key_name keywords
- keep_keys object_type
- ]
+class SplitOutputTest < Test::Unit::TestCase
+ def setup
+ Fluent::Test.setup
+ end
+
+ def create_driver(conf = CONFIG, tag='test')
+ d = Fluent::Test::BufferedOutputTestDriver.new(Fluent::SplitOutput, tag).configure(conf)
+ d
+ end
+
+ def test_configure_error
+ assert_raise(Fluent::ConfigError) {
+ d = create_driver %[
+ output_key keyword
+ format csv
+ key_name keywords
+ keep_keys site
+ ]
+ }
+
+ # not define output_key
+ assert_raise(Fluent::ConfigError) {
+ d = create_driver %[
+ output_tag split.keyword
+ format csv
+ key_name keywords
+ keep_keys site
+ ]
+ }
+
+ # not define output_key
+ assert_raise(Fluent::ConfigError) {
+ d = create_driver %[
+ output_key keyword
+ output_tag split.keyword
+ format csv
+ keep_keys site
+ ]
+ }
+
+ assert_raise(Fluent::ConfigError) {
+ d = create_driver %[
+ output_tag split.keyword
+ output_key keyword
+ ]
+ }
+
+ end
+
+ def test_configure
+ # not define format(default csv)
+ assert_nothing_raised(Fluent::ConfigError) {
+ d = create_driver %[
+ output_tag split.keyword
+ output_key keyword
+ key_name keywords
+ keep_keys site
+ ]
+ }
+
+ assert_nothing_raised(Fluent::ConfigError) {
+ d = create_driver %[
+ output_tag split.keyword
+ output_key keyword
+ key_name keywords
+ ]
+ }
+
+ end
end