Sha256: a8779e51aad272b3f58b53b1841c90bfedbebb6a8f04e7ced7c840f8c75b4dc7

Contents?: true

Size: 1.31 KB

Versions: 2

Compression:

Stored size: 1.31 KB

Contents

require File.join(File.dirname(__FILE__), 'setup')

class TestBucket < MiniTest::Unit::TestCase
  def setup
    config_fixture = json_fixture('buckets-config.json')
    Couchbase::Bucket.any_instance.stubs(:http_get).returns(config_fixture)
    Couchbase::Bucket.class_eval do
      alias :listen_for_config_changes_orig :listen_for_config_changes
      define_method :listen_for_config_changes do
        setup(config_fixture.first)
      end
    end
  end

  def teardown
    Couchbase::Bucket.class_eval do
      alias :listen_for_config_changes :listen_for_config_changes_orig
    end
  end

  def test_it_should_defaults_to_default_bucket_in_production_mode
    bucket = Couchbase.new('http://localhost:8091/pools/default')
    assert_equal 'default', bucket.name
    assert_equal :production, bucket.environment
  end

  def test_it_should_initialize_itself_from_config
    bucket = Couchbase.new('http://localhost:8091/pools/default')
    assert_equal 'http://localhost:8091/pools/default/buckets/default', bucket.uri.to_s
    assert_equal 'membase', bucket.type
    assert_equal 1, bucket.nodes.size
    assert_equal 256, bucket.vbuckets.size
  end

  def test_initialization_low_level_drivers
    bucket = Couchbase.new('http://localhost:8091/pools/default', :format => :plain)
    assert_equal :plain, bucket.default_format
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
couchbase-0.9.8 test/test_bucket.rb
couchbase-0.9.7 test/test_bucket.rb