Skip to content

Commit

Permalink
pass test with v0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
sonots committed Apr 23, 2015
1 parent 36363c6 commit 602ea4e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 25 deletions.
6 changes: 6 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,9 @@ Rake::TestTask.new(:test) do |test|
end

task :default => :test

desc 'Open an irb session preloaded with the gem library'
task :console do
sh 'irb -rubygems -I lib -r"fluent/load"'
end
task :c => :console
8 changes: 8 additions & 0 deletions test/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,12 @@
require 'fluent/plugin/filter_flowcounter_simple'

class Test::Unit::TestCase
def capture_log(log)
tmp = log.out
log.out = StringIO.new
yield
return log.out.string
ensure
log.out = tmp
end
end
19 changes: 5 additions & 14 deletions test/plugin/test_filter_flowcounter_simple.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ def test_filter
msgs << {'message'=> 'b' * 100}
end
d = create_driver
filtered, log = filter(d, msgs)
filtered, out = filter(d, msgs)
assert_equal msgs, filtered
assert( log.include?("count:20"), log )
assert( out.include?("count:20"), out )
end

private
Expand All @@ -39,20 +39,11 @@ def filter(d, msgs)
d.filter(msg, @time)
}
}
log = capture_log(d.instance.output.log) do
out = capture_log(d.instance.output.log) do
d.instance.flush_emit(0)
end
filtered = d.filtered_as_array
filtered_msgs = filtered.map {|m| m[2] }
[filtered_msgs, log]
[filtered_msgs, out]
end

def capture_log(log)
tmp = log.out
log.out = StringIO.new
yield
return log.out.string
ensure
log.out = tmp
end
end if defined?(Fluent::Test::FilterTestDriver)
end if defined?(Fluent::Filter)
11 changes: 0 additions & 11 deletions test/plugin/test_out_flowcounter_simple.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,4 @@ def test_comment
out = capture_log(d1.instance.log) { d1.instance.flush_emit(60) }
assert( out.include?("comment:foobar"), out )
end

private

def capture_log(log)
tmp = log.out
log.out = StringIO.new
yield
return log.out.string
ensure
log.out = tmp
end
end

0 comments on commit 602ea4e

Please sign in to comment.