Skip to content

Commit

Permalink
fix logger test for v0.10.47
Browse files Browse the repository at this point in the history
  • Loading branch information
sonots committed May 18, 2014
1 parent 3fd30f5 commit 6bbc3aa
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions test/plugin/test_out_flowcounter_simple.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ def test_num
d1.emit({'message'=> 'c' * 100})
end
end
log = capture_log { d1.instance.flush_emit(60) }
assert( log.include?("count:30"), log )
out = capture_log(d1.instance.log) { d1.instance.flush_emit(60) }
assert( out.include?("count:30"), out )
end

def test_byte
Expand All @@ -50,8 +50,8 @@ def test_byte
d1.emit({'message'=> 'c' * 100})
end
end
log = capture_log { d1.instance.flush_emit(60) }
assert( log.include?("count:3360"), log )
out = capture_log(d1.instance.log) { d1.instance.flush_emit(60) }
assert( out.include?("count:3360"), out )
end

def test_comment
Expand All @@ -63,18 +63,18 @@ def test_comment
d1.emit({'message'=> 'c' * 100})
end
end
log = capture_log { d1.instance.flush_emit(60) }
assert( log.include?("comment:foobar"), log )
out = capture_log(d1.instance.log) { d1.instance.flush_emit(60) }
assert( out.include?("comment:foobar"), out )
end

private

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

0 comments on commit 6bbc3aa

Please sign in to comment.