test/test_redis-stat.rb in redis-stat-0.4.12-java vs test/test_redis-stat.rb in redis-stat-0.4.13

- old
+ new

@@ -1,17 +1,18 @@ #!/usr/bin/env ruby # encoding: utf-8 $VERBOSE = true -$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) +$LOAD_PATH.unshift(File.expand_path('../lib', __FILE__)) require 'rubygems' +require 'bundler/setup' require 'redis-stat' require 'redis' require 'stringio' require 'minitest/autorun' -class TestRedisStat < MiniTest::Unit::TestCase +class TestRedisStat < MiniTest::Test def test_humanize_number rs = RedisStat.new assert_equal '0', rs.send(:humanize_number, 0.00) assert_equal '7', rs.send(:humanize_number, 7) assert_equal '0.01', rs.send(:humanize_number, 0.00751) @@ -178,22 +179,22 @@ def test_start csv = '/tmp/redis-stat.csv' cnt = 100 rs = RedisStat.new :hosts => %w[localhost] * 5, :interval => 0.01, :count => cnt, - :verbose => true, :csv_file => csv, :auth => 'pw' + :verbose => true, :csv_file => csv rs.start $stdout assert_equal cnt + 1, File.read(csv).lines.to_a.length ensure File.unlink csv end def test_mono [true, false].each do |mono| rs = RedisStat.new :hosts => %w[localhost] * 5, :interval => 0.02, :count => 20, - :verbose => true, :auth => 'pw', :mono => mono + :verbose => true, :mono => mono output = StringIO.new rs.start output puts output.string assert_equal mono, output.string !~ /\e\[\d*(;\d+)*m/ end @@ -203,11 +204,10 @@ # prerequisite r1 = Redis.new(:host => 'localhost') r2 = Redis.new(:host => 'localhost', :port => 6380) if r1.info['redis_version'] =~ /^2\.4/ && r2.info['redis_version'] =~ /^2\.2/ - rs = RedisStat.new :hosts => %w[localhost:6380 localhost], :interval => 1, :count => 1, - :auth => 'pw', :style => :ascii + rs = RedisStat.new :hosts => %w[localhost:6380 localhost], :interval => 1, :count => 1, :style => :ascii output = StringIO.new rs.start output vline = output.string.lines.select { |line| line =~ /gcc_version/ }.first puts vline.gsub(/ +/, ' ') assert vline.gsub(/ +/, ' ').include?('| | 4.2.1 |')