Sha256: cde8127f2edf786d002268bb864b7704cae4b876243b675205d603070c1d93f7

Contents?: true

Size: 1.38 KB

Versions: 3

Compression:

Stored size: 1.38 KB

Contents

require File.expand_path("../../test_helper", __FILE__)

class GridTest < Test::Unit::TestCase

  context "GridFS: " do
    setup do
      @conn   = stub()
      @conn.stubs(:safe)
      @conn.stubs(:read_preference)
      @conn.stubs(:tag_sets)
      @conn.stubs(:acceptable_latency)
      @db     = DB.new("testing", @conn)
      @files  = mock()
      @chunks = mock()

      @db.expects(:[]).with('fs.files').returns(@files)
      @db.expects(:[]).with('fs.chunks').returns(@chunks)
      @db.stubs(:safe)
      @db.stubs(:read_preference)
    end

    context "Grid classe with standard connections" do
      setup do
        @conn.expects(:class).returns(Connection)
        @conn.expects(:read_primary?).returns(true)
      end

      should "create indexes for Grid" do
        @chunks.expects(:create_index)
        Grid.new(@db)
      end

      should "create indexes for GridFileSystem" do
        @files.expects(:create_index)
        @chunks.expects(:create_index)
        GridFileSystem.new(@db)
      end
    end

    context "Grid classes with slave connection" do
      setup do
        @conn.expects(:class).twice.returns(Connection)
        @conn.expects(:read_primary?).returns(false)
      end

      should "not create indexes for Grid" do
        Grid.new(@db)
      end

      should "not create indexes for GridFileSystem" do
        GridFileSystem.new(@db)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mongo-1.7.1 test/unit/grid_test.rb
mongo-1.7.0 test/unit/grid_test.rb
mongo-1.7.0.rc0 test/unit/grid_test.rb