Skip to content

Commit

Permalink
Benchmark filter safe for serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
ulm committed Oct 31, 2019
1 parent ea3d1d0 commit 7655862
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
41 changes: 41 additions & 0 deletions spec/features/batch_publishing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -214,4 +214,45 @@ def expect_message(attributes, model_name = "TestUser", routing_key = "TestUser"
end
end
end

context "#filter_safe_for_serialization" do
let(:attributes) do
{"id"=>17,
"parent_id"=>17,
"session_id"=>14,
"user_id"=>1,
"game_id"=>103,
"time"=>Time.current.to_s,
"points"=>0.0,
"new_points"=>0.0,
"session_type"=>"real",
"info"=>"<roundnum id=\"709640453\"></roundnum><giftspin gift_id=\"18\"></giftspin>",
"roundnum"=>709640453,
"eapi_session_id"=>"test",
"type"=>"giftspin",
"currency"=>"EUR",
"courses"=>{"EUR"=>"1.0", "NGN"=>"402.7818871582", "NOK"=>"10.1745883192", "PLN"=>"4.2788622234", "RUB"=>"70.9193807518", "SEK"=>"10.7375715846", "USD"=>"1.1141564721"},
"data"=>{"provider"=>"playson", "roulette_numbers_covered"=>"0"},
"bet"=>0.12e4,
"win"=>0.3e3,
"new_balance"=>0.1036e6,
"total_win"=>0.3e3,
"jurisdiction"=>"CW",
"finish_time"=> Time.current.to_s,
"status"=>"finished",
"bonus_bet"=>0.0,
"bonus_win"=>0.3e3,
"total_bonus_win"=>0.3e3,
"parent_id_new"=>nil,
"roundnum_new"=>"709640453"
}
end

it "allocates limited amount of objects" do

expect {
TableSync::Publisher.new(model_name, attributes, options).send :filter_safe_for_serialization, attributes
}.to perform_allocation({Array => 1, Object => 2}).objects
end
end
end
3 changes: 3 additions & 0 deletions spec/support/database_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

require "sequel"
require "active_record"
require "rspec-benchmark"

Sequel.extension :pg_json_ops
DB_NAME = (ENV["DB_NAME"] || "table_sync_test").freeze
Expand Down Expand Up @@ -93,6 +94,8 @@ def connect(db_url)
SQL

RSpec.configure do |config|
config.include RSpec::Benchmark::Matchers

config.before do
schemas_tables = DB[:pg_tables].where(schemaname: %w[public custom_schema])
.select_hash(:tablename, :schemaname)
Expand Down
1 change: 1 addition & 0 deletions table_sync.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Gem::Specification.new do |spec|

spec.add_development_dependency "coveralls", "~> 0.8"
spec.add_development_dependency "rspec", "~> 3.8"
spec.add_development_dependency "rspec-benchmark"
spec.add_development_dependency "rubocop-config-umbrellio", "~> 0.74"
spec.add_development_dependency "simplecov", "~> 0.16"

Expand Down

0 comments on commit 7655862

Please sign in to comment.