Sha256: fb02f2643cbaef4f2beecffd73f6fcd4d27a4416b1bd09f81764408a97a548a7

Contents?: true

Size: 1.5 KB

Versions: 25

Compression:

Stored size: 1.5 KB

Contents

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

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

require 'lhm/table'
require 'lhm/migrator'

describe Lhm::Intersection do
  include UnitHelper

  it 'should not have dropped changes' do
    origin = Lhm::Table.new('origin')
    origin.columns['dropped']  = varchar
    origin.columns['retained'] = varchar

    destination = Lhm::Table.new('destination')
    destination.columns['retained'] = varchar

    intersection = Lhm::Intersection.new(origin, destination)
    value(intersection.destination.include?('dropped')).must_equal(false)
  end

  it 'should have unchanged columns' do
    origin = Lhm::Table.new('origin')
    origin.columns['dropped']  = varchar
    origin.columns['retained'] = varchar

    destination = Lhm::Table.new('destination')
    destination.columns['retained'] = varchar

    intersection = Lhm::Intersection.new(origin, destination)
    value(intersection.destination).must_equal(['retained'])
  end

  it 'should have renamed columns' do
    origin = Lhm::Table.new('origin')
    origin.columns['old_name']  = varchar

    destination = Lhm::Table.new('destination')
    destination.columns['new_name'] = varchar

    intersection = Lhm::Intersection.new(origin, destination, { 'old_name' => 'new_name' })
    value(intersection.origin).must_equal(['old_name'])
    value(intersection.destination).must_equal(['new_name'])
  end

  def varchar
    { :metadata => 'VARCHAR(255)' }
  end
end

Version data entries

25 entries across 25 versions & 2 rubygems

Version Path
lhm-shopify-4.5.0 spec/unit/intersection_spec.rb
lhm-shopify-4.4.2 spec/unit/intersection_spec.rb
lhm-shopify-4.4.1 spec/unit/intersection_spec.rb
lhm-shopify-4.4.0 spec/unit/intersection_spec.rb
lhm-shopify-4.3.0 spec/unit/intersection_spec.rb
lhm-shopify-4.2.3 spec/unit/intersection_spec.rb
lhm-shopify-4.2.2 spec/unit/intersection_spec.rb
lhm-shopify-4.2.1 spec/unit/intersection_spec.rb
lhm-shopify-4.2.0 spec/unit/intersection_spec.rb
lhm-shopify-4.1.1 spec/unit/intersection_spec.rb
lhm-shopify-4.1.0 spec/unit/intersection_spec.rb
lhm-shopify-4.0.0 spec/unit/intersection_spec.rb
lhm-teak-3.6.4 spec/unit/intersection_spec.rb
lhm-teak-3.6.3 spec/unit/intersection_spec.rb
lhm-teak-3.6.2 spec/unit/intersection_spec.rb
lhm-teak-3.6.1 spec/unit/intersection_spec.rb
lhm-teak-3.6.0 spec/unit/intersection_spec.rb
lhm-shopify-3.5.5 spec/unit/intersection_spec.rb
lhm-shopify-3.5.4 spec/unit/intersection_spec.rb
lhm-shopify-3.5.3 spec/unit/intersection_spec.rb