Sha256: 92a9b11cadfa85e4eb0b8903cfc345c7b2c5cfdd1665277bb92de2b4a59d83d8
Contents?: true
Size: 1.32 KB
Versions: 34
Compression:
Stored size: 1.32 KB
Contents
require 'spec_helper' require 'flydata/query_based_sync/record_size_estimator' module Flydata module QueryBasedSync describe RecordSizeEstimator do def actual_record_size(table_name, record) j = { row: record, type: :update, respect_order: true, src_pos: "10051:10051:\t10520:10052:\t{\"id\":\"1000000000\"}", v: 2, seq: 1000000000, table_name: table_name, table_rev: 1, }.to_json.size end let(:table_name) { 'table_1' } let(:num_columns) { 2 } let(:subject_object) { described_class.new(table_name, num_columns) } describe '#calc_record_size' do def create_record(num_records = 10) 1.upto(num_records).inject({}){|h, i| h[i.to_s]=i.to_s ;h} end let(:num_columns) { record.values.count } subject { subject_object.calc_record_size(record) } let(:actual_size) { actual_record_size(table_name, record) } context 'when number of columns is small' do let(:record) { create_record(2) } it { is_expected.to eq(actual_size) } end context 'when number of columns is medium' do let(:record) { create_record(12) } it { is_expected.to eq(actual_size) } end context 'when number of columns is big' do let(:record) { create_record(102) } it { is_expected.to eq(actual_size) } end end end end end
Version data entries
34 entries across 34 versions & 1 rubygems