Sha256: 8eef473e29de46984c6cb93ed7bb55f255dd5c5fb9f7f46a7ed33e269cf2a81f
Contents?: true
Size: 1.46 KB
Versions: 3
Compression:
Stored size: 1.46 KB
Contents
require 'test/unit' require "#{File.dirname(__FILE__)}/../lib/rails_analyzer/log_parser" require "#{File.dirname(__FILE__)}/../lib/rails_analyzer/record_inserter" class RecordInserterTest < Test::Unit::TestCase def fragment_file(number) "#{File.dirname(__FILE__)}/log_fragments/fragment_#{number}.log" end def setup File.delete('_tmp.db') if File.exist?('_tmp.db') end def teardown File.delete('_tmp.db') if File.exist?('_tmp.db') end def test_insert_log_fragment db = RailsAnalyzer::RecordInserter.insert_batch_into('_tmp.db') do |batch| RailsAnalyzer::LogParser.new(fragment_file(1)).each { |request| batch.insert(request) } end assert_equal 4, db.database.get_first_value("SELECT COUNT(*) FROM started_requests").to_i assert_equal 4, db.database.get_first_value("SELECT COUNT(*) FROM completed_requests").to_i end def test_insert_multiple_fragments RailsAnalyzer::RecordInserter.insert_batch_into('_tmp.db') do |batch| RailsAnalyzer::LogParser.new(fragment_file(1)).each { |request| batch.insert(request) } end db = RailsAnalyzer::RecordInserter.insert_batch_into('_tmp.db') do |batch| RailsAnalyzer::LogParser.new(fragment_file(2)).each { |request| batch.insert(request) } end assert_equal 5, db.database.get_first_value("SELECT COUNT(*) FROM started_requests").to_i assert_equal 5, db.database.get_first_value("SELECT COUNT(*) FROM completed_requests").to_i end end
Version data entries
3 entries across 3 versions & 1 rubygems