Sha256: ac18c1a7f266474252c578a753b11ac72e04d44b366e9a783b25254d5999c678

Contents?: true

Size: 1.82 KB

Versions: 10

Compression:

Stored size: 1.82 KB

Contents

# Copyright (c) 2011 - 2013, SoundCloud Ltd., Rany Keddo, Tobias Bielohlawek, Tobias
# Schmidt

require File.expand_path(File.dirname(__FILE__)) + '/integration_helper'

require 'lhm/table'
require 'lhm/migration'
require 'lhm/entangler'
require 'lhm/connection'

describe Lhm::Entangler do
  include IntegrationHelper

  before(:each) { connect_master! }

  describe 'entanglement' do
    before(:each) do
      @origin = table_create('origin')
      @destination = table_create('destination')
      @migration = Lhm::Migration.new(@origin, @destination)
      @connection = Lhm::Connection.new(connection: connection)
      @entangler = Lhm::Entangler.new(@migration, @connection)
    end

    it 'should replay inserts from origin into destination' do
      @entangler.run do
        execute("insert into origin (common) values ('inserted')")
      end

      slave do
        value(count(:destination, 'common', 'inserted')).must_equal(1)
      end
    end

    it 'should replay deletes from origin into destination' do
      execute("insert into origin (common) values ('inserted')")

      @entangler.run do
        execute("delete from origin where common = 'inserted'")
      end

      slave do
        value(count(:destination, 'common', 'inserted')).must_equal(0)
      end
    end

    it 'should replay updates from origin into destination' do
      @entangler.run do
        execute("insert into origin (common) values ('inserted')")
        execute("update origin set common = 'updated'")
      end

      slave do
        value(count(:destination, 'common', 'updated')).must_equal(1)
      end
    end

    it 'should remove entanglement' do
      @entangler.run {}

      execute("insert into origin (common) values ('inserted')")

      slave do
        value(count(:destination, 'common', 'inserted')).must_equal(0)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
lhm-teak-3.6.4 spec/integration/entangler_spec.rb
lhm-teak-3.6.3 spec/integration/entangler_spec.rb
lhm-teak-3.6.2 spec/integration/entangler_spec.rb
lhm-teak-3.6.1 spec/integration/entangler_spec.rb
lhm-teak-3.6.0 spec/integration/entangler_spec.rb
lhm-shopify-3.5.5 spec/integration/entangler_spec.rb
lhm-shopify-3.5.4 spec/integration/entangler_spec.rb
lhm-shopify-3.5.3 spec/integration/entangler_spec.rb
lhm-shopify-3.5.2 spec/integration/entangler_spec.rb
lhm-shopify-3.5.1 spec/integration/entangler_spec.rb