Sha256: 483032f0000fa0102a06ae4f6a04170333a58378cdb35f19b97c6a102444afdc

Contents?: true

Size: 1.21 KB

Versions: 3

Compression:

Stored size: 1.21 KB

Contents

require 'spec_helper'

describe Octoshark do

  describe ".reset_connection_managers!" do
    it "resets connection managers" do
      manager = Octoshark::ConnectionManager.new(configs)
      old_pools = manager.connection_pools.map(&:object_id)

      Octoshark.reset_connection_managers!

      new_pools = manager.connection_pools.map(&:object_id)
      expect(new_pools).to_not eq(old_pools)
    end
  end

  describe ".disconnect!" do
    it "disconnects connection managers" do
      manager = Octoshark::ConnectionManager.new(configs)

      Octoshark.disconnect!

      expect(Octoshark.connection_managers).to be_blank
    end

    it "cleans old connections" do
      manager = Octoshark::ConnectionManager.new(configs)

      manager.with_connection(:db1) { |connection| connection.execute("SELECT 1") }
      manager.with_connection(:db2) { |connection| connection.execute("SELECT 1") }
      expect(manager.connection_pools[:db1].connections.count).to eq(1)
      expect(manager.connection_pools[:db2].connections.count).to eq(1)

      Octoshark.disconnect!

      expect(manager.connection_pools[:db1].connections.count).to eq(0)
      expect(manager.connection_pools[:db2].connections.count).to eq(0)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
octoshark-0.1.2 spec/octoshark_spec.rb
octoshark-0.1.1 spec/octoshark_spec.rb
octoshark-0.1.0 spec/octoshark_spec.rb