Skip to content

Commit

Permalink
Breadcrumbs/Mongo integration: Test improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Cawllec committed Jan 10, 2019
1 parent be506d3 commit 4f90ce7
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions spec/integrations/mongo_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
@mocked_mongo = true
module ::Mongo
module Monitoring
COMMAND = 'command'
COMMAND = 'Command'
module Global
end
end
Expand Down Expand Up @@ -54,7 +54,7 @@ def require(path)
end

describe "#failed" do
it "calls #leave_mongo_beradcrumb with the event_name and event" do
it "calls #leave_mongo_breadcrumb with the event_name and event" do
event = double
expect(subscriber).to receive(:leave_mongo_breadcrumb).with("failed", event)
subscriber.failed(event)
Expand Down Expand Up @@ -181,14 +181,6 @@ def require(path)
it "calls into #sanitize_filter_value with the value from each {k,v} pair" do
expect(subscriber.send(:sanitize_filter_hash, {:a => 1, :b => 2})).to eq({:a => '?', :b => '?'})
end

it "defaults the depth to 0" do
subscriber.send(:sanitize_filter_hash, {:a => 1})
end

it "passes through a given depth" do
subscriber.send(:sanitize_filter_hash, {:a => 1}, 3)
end
end

describe "#sanitize_filter_value" do
Expand All @@ -200,18 +192,14 @@ def require(path)
end

it "is recursive and iterative for array values" do
expect(subscriber.send(:sanitize_filter_value, [1, 2, 3], 0)).to eq(['?', '?', '?'])
expect(subscriber.send(:sanitize_filter_value, [1, [2, [3]]], 0)).to eq(['?', ['?', ['?']]])
end

it "calls #santize_filter_hash for hash values" do
expect(subscriber).to receive(:sanitize_filter_hash).with({:a => 1}, 1)
subscriber.send(:sanitize_filter_value, {:a => 1}, 0)
end

it "increments the depth for each call" do
expect(subscriber.send(:sanitize_filter_value, [1, [2, [3]]], 0)).to eq(['?', ['?', ['?']]])
end

it "returns [MAX_FILTER_DEPTH_REACHED] if the filter depth is exceeded" do
expect(subscriber.send(:sanitize_filter_value, 1, 4)).to eq('[MAX_FILTER_DEPTH_REACHED]')
end
Expand Down

0 comments on commit 4f90ce7

Please sign in to comment.