Sha256: 58f80a20dcaf378b1fdd7fa588450619a264ab74553d73ee4a3046876902eb53

Contents?: true

Size: 1.56 KB

Versions: 414

Compression:

Stored size: 1.56 KB

Contents

require "appsignal/integrations/data_mapper"

describe Appsignal::Hooks::DataMapperLogListener do
  module DataMapperLog
    def log(message)
    end
  end

  describe "#log" do
    let(:transaction) { double }
    let(:message) do
      double(
        :query    => "SELECT * from users",
        :duration => 100
      )
    end
    let(:connection_class) do
      module DataObjects
        module Sqlite3
          class Connection
            include DataMapperLog
            include Appsignal::Hooks::DataMapperLogListener
          end
        end
      end
    end

    before { allow(Appsignal::Transaction).to receive(:current) { transaction } }

    it "should record the log entry in an event" do
      expect(transaction).to receive(:record_event).with(
        "query.data_mapper",
        "DataMapper Query",
        "SELECT * from users",
        100,
        Appsignal::EventFormatter::SQL_BODY_FORMAT
      )
    end

    context "when scheme is not sql-like" do
      let(:connection_class) do
        module DataObjects
          module MongoDB
            class Connection
              include DataMapperLog
              include Appsignal::Hooks::DataMapperLogListener
            end
          end
        end
      end

      it "should record the log entry in an event without body" do
        expect(transaction).to receive(:record_event).with(
          "query.data_mapper",
          "DataMapper Query",
          "",
          100,
          Appsignal::EventFormatter::DEFAULT
        )
      end
    end

    after { connection_class.new.log(message) }
  end
end

Version data entries

414 entries across 414 versions & 1 rubygems

Version Path
appsignal-3.13.1-java spec/lib/appsignal/integrations/data_mapper_spec.rb
appsignal-3.13.1 spec/lib/appsignal/integrations/data_mapper_spec.rb
appsignal-3.13.1.alpha.1-java spec/lib/appsignal/integrations/data_mapper_spec.rb
appsignal-3.13.1.alpha.1 spec/lib/appsignal/integrations/data_mapper_spec.rb
appsignal-3.13.0-java spec/lib/appsignal/integrations/data_mapper_spec.rb
appsignal-3.13.0 spec/lib/appsignal/integrations/data_mapper_spec.rb
appsignal-3.12.6-java spec/lib/appsignal/integrations/data_mapper_spec.rb
appsignal-3.12.6 spec/lib/appsignal/integrations/data_mapper_spec.rb
appsignal-3.12.5-java spec/lib/appsignal/integrations/data_mapper_spec.rb
appsignal-3.12.5 spec/lib/appsignal/integrations/data_mapper_spec.rb
appsignal-3.12.4-java spec/lib/appsignal/integrations/data_mapper_spec.rb
appsignal-3.12.4 spec/lib/appsignal/integrations/data_mapper_spec.rb
appsignal-3.12.3-java spec/lib/appsignal/integrations/data_mapper_spec.rb
appsignal-3.12.3 spec/lib/appsignal/integrations/data_mapper_spec.rb
appsignal-3.12.2-java spec/lib/appsignal/integrations/data_mapper_spec.rb
appsignal-3.12.2 spec/lib/appsignal/integrations/data_mapper_spec.rb
appsignal-3.12.1-java spec/lib/appsignal/integrations/data_mapper_spec.rb
appsignal-3.12.1 spec/lib/appsignal/integrations/data_mapper_spec.rb
appsignal-3.12.0-java spec/lib/appsignal/integrations/data_mapper_spec.rb
appsignal-3.12.0 spec/lib/appsignal/integrations/data_mapper_spec.rb