fluent-migrator-command-runner 0.0.2 → 0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1120833152bd2339e2fd3eb88b4c8bff2033a9c7ad52853f28d8c9d1d3b25f1c
4
+ data.tar.gz: 0ebe5e145df2af646fe8b763ceb995665fccacc090000da1f67fcc01726512d4
5
+ SHA512:
6
+ metadata.gz: 877f043fcc0648d79e2d16e2f6c2378a0412e44a20a53d624e50312b0a5ca164272dcc65612bb402e5b4bc5498429e000089930da1097a44eaf04cb353f11517
7
+ data.tar.gz: 4ba5084b4d3727aa0307e448ac789596084f8b47154333cd35fb7c2505f8ffe02a9fe0acf25b64ec75d8b246272f32bf0ab9ae2908550b399d6199ff1e5411d7
@@ -0,0 +1,2 @@
1
+ .idea
2
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'rake'
4
+ gem 'rspec'
5
+ gem 'rspec-mocks'
6
+
7
+ gemspec
@@ -0,0 +1,39 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ fluent-migrator-command-runner (0.7)
5
+ fig_newton
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ diff-lcs (1.2.5)
11
+ fig_newton (1.0)
12
+ yml_reader (>= 0.7)
13
+ rake (10.3.2)
14
+ rspec (3.1.0)
15
+ rspec-core (~> 3.1.0)
16
+ rspec-expectations (~> 3.1.0)
17
+ rspec-mocks (~> 3.1.0)
18
+ rspec-core (3.1.4)
19
+ rspec-support (~> 3.1.0)
20
+ rspec-expectations (3.1.1)
21
+ diff-lcs (>= 1.2.0, < 2.0)
22
+ rspec-support (~> 3.1.0)
23
+ rspec-mocks (3.1.1)
24
+ rspec-support (~> 3.1.0)
25
+ rspec-support (3.1.0)
26
+ yml_reader (0.7)
27
+
28
+ PLATFORMS
29
+ x64-mingw32
30
+ x86-mingw32
31
+
32
+ DEPENDENCIES
33
+ fluent-migrator-command-runner!
34
+ rake
35
+ rspec
36
+ rspec-mocks
37
+
38
+ BUNDLED WITH
39
+ 2.1.4
@@ -0,0 +1,58 @@
1
+ #Fluent-Migrator-Command-Runner
2
+
3
+ Build and run fluent migrator commands from ruby with ease.
4
+
5
+ #Installation
6
+
7
+ gem install fluent-migrator-command-runner
8
+
9
+ #Setup
10
+
11
+ FigNewton file (ex. local.yml) should be loaded before use.
12
+ [FigNewton will automatically load file if ENV['FIG_NEWTOW_FILE'] is set]
13
+
14
+ The FigNewton file should have atleast the following nodes.
15
+
16
+ ````
17
+ path_to_migration_assembly: ../Path/To/Migrations.dll
18
+ path_to_migrator_exe: ../Path/to/migrate.exe
19
+
20
+ database:
21
+ adapter: oracle_enhanced
22
+ database: "TNS.world"
23
+ username: "SCHEMA_USER_NAME"
24
+ password: "p4ssw0rd"
25
+ ````
26
+
27
+ #Optional Overrides
28
+
29
+ ##Oracle Data Provider
30
+
31
+ Defaults to use the unmanaged oracle client
32
+
33
+ ````
34
+ migration_provider: oraclemanaged
35
+ ````
36
+
37
+ #Using exposed rake task
38
+
39
+ Migrate with no tags or profiles
40
+
41
+ ````ruby
42
+ FluentMigratorCommandRunner::Rake::Task.new(:migrate)
43
+ ````
44
+
45
+ Migrate with profile, tag, and select a fig newton file
46
+
47
+ ````ruby
48
+ FluentMigratorCommandRunner::Rake::Task.new(:migrate) do |t|
49
+ t.fig_newton_file = 'local.yml'
50
+ t.profile = 'TestData'
51
+ t.tag = 'Tag'
52
+ end
53
+ ````
54
+
55
+ #Future Enhancements
56
+ - be able to run with multiple tags
57
+
58
+ #Notes
@@ -0,0 +1,8 @@
1
+ require 'rspec/core/rake_task'
2
+ require "bundler/gem_tasks"
3
+
4
+ RSpec::Core::RakeTask.new(:spec) do |spec|
5
+ spec.pattern = ['spec/**/*_spec.rb']
6
+ end
7
+
8
+ task :spec
@@ -0,0 +1,18 @@
1
+ require File.expand_path('../lib/fluent-migrator-command-runner/version', __FILE__)
2
+
3
+ Gem::Specification.new do |gem|
4
+ gem.name = 'fluent-migrator-command-runner'
5
+ gem.date = '2014-11-11'
6
+ gem.description = "Build and Execute Fluent Migrator Commands"
7
+ gem.authors = ["Mosaic"]
8
+ gem.email = 'mosaic.development@sherwin.com'
9
+ gem.homepage = 'Internal @ SherwinWilliams'
10
+ gem.summary = "Rake Tasks For Fluent Migrator"
11
+ gem.files = `git ls-files`.split("\n")
12
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
13
+ gem.require_paths = ['lib']
14
+ gem.version = FluentMigratorCommandRunner::VERSION
15
+ gem.homepage = ''
16
+ gem.license = 'MIT'
17
+ gem.add_dependency 'fig_newton'
18
+ end
@@ -1,4 +1,10 @@
1
+ require 'fluent-migrator-command-runner/version'
1
2
  require 'fluent-migrator-command-runner/runner'
3
+ require 'fluent-migrator-command-runner/command_builder'
4
+ require 'fluent-migrator-command-runner/commands/migration_command'
5
+ require 'fluent-migrator-command-runner/commands/oracle_migration_command'
6
+ require 'fluent-migrator-command-runner/commands/sql_server_migration_command'
7
+ require 'fluent-migrator-command-runner/task'
2
8
  require 'fig_newton'
3
9
 
4
10
  module FluentMigratorCommandRunner
@@ -1,21 +1,15 @@
1
-
2
1
  module FluentMigratorCommandRunner
3
2
 
4
3
  class CommandBuilder
5
4
 
6
- def self.build (configuration, task, profile = nil, tag=nil)
7
- connection_string = build_connection_string(configuration[:connection_information])
8
- command = "#{configuration[:path_to_migrator]} --conn \"#{connection_string}\" /provider oracle --assembly \"#{configuration[:path_to_migration_assembly]}\" /task #{task}"
9
- command += " --tag #{tag}" if tag
10
- command += " --profile=#{profile}" if profile
11
- command
12
- end
13
-
14
- private
15
-
16
- def self.build_connection_string(configuration)
17
- "DATA SOURCE=#{configuration['database']};user id=#{configuration['username']};password=#{configuration['password']}"
5
+ def self.build(migration_options = {})
6
+ if FigNewton.migration_provider == 'sqlserver'
7
+ command = SqlServerMigrationCommand.new(migration_options)
8
+ else
9
+ command = OracleMigrationCommand.new(migration_options)
18
10
  end
11
+ command.build
12
+ end
19
13
 
20
14
  end
21
15
  end
@@ -0,0 +1,40 @@
1
+ module FluentMigratorCommandRunner
2
+ class MigrationCommand
3
+ attr_reader :path_to_migrator,
4
+ :path_to_migration_assembly,
5
+ :connection_information,
6
+ :profile,
7
+ :tag,
8
+ :provider
9
+
10
+ PARAMETER_PREFIX = '--'
11
+ SPACE_CHAR = "\s"
12
+
13
+ MIGRATOR_DELIMITER = "#{SPACE_CHAR + PARAMETER_PREFIX}"
14
+ CONNECTION_STRING_DELIMITER = ';'
15
+
16
+ def initialize(options = {})
17
+ @profile = options[:profile] unless options[:profile].nil?
18
+ @tag = options[:tag] unless options[:tag].nil?
19
+ @provider = FigNewton.migration_provider('oracle')
20
+ @path_to_migrator = FigNewton.path_to_migrator_exe
21
+ @path_to_migration_assembly = FigNewton.path_to_migration_assembly
22
+ @connection_information = FigNewton.database.to_hash
23
+ @connection_information['password'] = options[:db_password] unless options[:db_password].nil?
24
+ end
25
+
26
+ def build
27
+ connection_string = build_connection_string(@connection_information)
28
+
29
+ command_sections = []
30
+ command_sections.push(@path_to_migrator)
31
+ command_sections.push("provider #{@provider}")
32
+ command_sections.push("conn \"#{connection_string}\"")
33
+ command_sections.push('task migrate')
34
+ command_sections.push("assembly \"#{@path_to_migration_assembly}\"")
35
+ command_sections.push("tag #{@tag}") if @tag
36
+ command_sections.push("profile=#{@profile}") if @profile
37
+ command_sections.join(MIGRATOR_DELIMITER)
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,15 @@
1
+ module FluentMigratorCommandRunner
2
+ class OracleMigrationCommand < MigrationCommand
3
+
4
+ protected
5
+
6
+ def build_connection_string(connection_information)
7
+ connection = []
8
+ connection.push("DATA SOURCE=#{connection_information['database']}")
9
+ connection.push("user id=#{connection_information['username']}")
10
+ connection.push("password=#{connection_information['password']}")
11
+ connection.join(CONNECTION_STRING_DELIMITER)
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module FluentMigratorCommandRunner
2
+ class SqlServerMigrationCommand < MigrationCommand
3
+
4
+ protected
5
+
6
+ def build_connection_string(connection_information)
7
+ connection = []
8
+ connection.push("Server=#{connection_information['host']}")
9
+ connection.push("Database=#{connection_information['database']}")
10
+ connection.push("user id=#{connection_information['username']}")
11
+ connection.push("password=#{connection_information['password']}")
12
+ connection.join(CONNECTION_STRING_DELIMITER)
13
+ end
14
+ end
15
+ end
@@ -1,20 +1,15 @@
1
- require_relative 'command_builder'
2
-
3
1
  module FluentMigratorCommandRunner
4
2
  class Runner
5
3
 
6
- def initialize(overrides = {})
7
- defaults = {
8
- :path_to_migrator => FigNewton.path_to_migrator_exe,
9
- :path_to_migration_assembly => FigNewton.path_to_migration_assembly,
10
- :connection_information => FigNewton.database.to_hash
11
- }
12
- @configuration = defaults.merge(overrides)
4
+ def self.execute(command)
5
+ Kernel.system(command)
6
+ raise 'Fluent Migrator Failed' unless fluent_migrator_run_succeeded?
13
7
  end
14
8
 
15
- def migrate_database(profile = nil, tag = nil)
16
- command = CommandBuilder.build(@configuration, 'migrate', profile, tag)
17
- Kernel.system command
9
+ private
10
+
11
+ def self.fluent_migrator_run_succeeded?
12
+ $?.exitstatus == 0
18
13
  end
19
14
 
20
15
  end
@@ -0,0 +1,44 @@
1
+ require 'fig_newton'
2
+ require 'rake'
3
+
4
+ require File.dirname(__FILE__) + "/runner"
5
+ require File.dirname(__FILE__) + "/command_builder"
6
+
7
+
8
+ module FluentMigratorCommandRunner
9
+ module Rake
10
+ class Task
11
+ include ::Rake::DSL
12
+
13
+ attr_accessor :fig_newton_file
14
+ attr_accessor :profile
15
+ attr_accessor :tag
16
+
17
+ def initialize(task_name)
18
+ @task_name = task_name
19
+
20
+ yield self if block_given?
21
+
22
+ define_task
23
+ end
24
+
25
+ def define_task
26
+ task @task_name, [:password] do |t, params|
27
+ FigNewton.load(@fig_newton_file) unless @fig_newton_file.nil?
28
+ options = migration_options
29
+ options[:db_password] = params[:password] unless params[:password].nil?
30
+ command = CommandBuilder.build(options)
31
+ Runner.execute(command)
32
+ end
33
+ end
34
+
35
+ def migration_options
36
+ options = {}
37
+ options[:profile] = profile unless profile.nil?
38
+ options[:tag] = tag unless tag.nil?
39
+ return options
40
+ end
41
+
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,3 @@
1
+ module FluentMigratorCommandRunner
2
+ VERSION = "0.7"
3
+ end
@@ -0,0 +1,32 @@
1
+
2
+ require 'spec_helper'
3
+
4
+ describe FluentMigratorCommandRunner::CommandBuilder do
5
+
6
+ let(:builder){FluentMigratorCommandRunner::CommandBuilder}
7
+ let(:oracle_command){FluentMigratorCommandRunner::OracleMigrationCommand}
8
+ let(:command_stub){double(FluentMigratorCommandRunner::OracleMigrationCommand)}
9
+
10
+ before { allow(oracle_command).to receive(:new).and_return(command_stub)}
11
+ before { allow(command_stub).to receive(:build)}
12
+ before { allow(FigNewton).to receive(:migration_provider).and_return('')}
13
+
14
+ it 'should create new oracle migration command with options' do
15
+ expected_options = {}
16
+ builder.build(expected_options)
17
+ expect(oracle_command).to have_received(:new).with(expected_options)
18
+ end
19
+
20
+ it 'should build oracle migration command ' do
21
+ builder.build
22
+ expect(command_stub).to have_received(:build)
23
+ end
24
+
25
+ it 'should return built oracle migration command ' do
26
+ expected_command = "command string"
27
+ allow(command_stub).to receive(:build).and_return(expected_command)
28
+ actual = builder.build
29
+ expect(actual).to be(expected_command)
30
+ end
31
+
32
+ end
@@ -0,0 +1,116 @@
1
+ require 'spec_helper'
2
+ require 'socket'
3
+
4
+ describe FluentMigratorCommandRunner::OracleMigrationCommand do
5
+
6
+ before do
7
+ @connection_information = {
8
+ 'database' => '',
9
+ 'username' => '',
10
+ 'password' => ''
11
+ }
12
+ allow(FigNewton).to receive(:database).and_return(@connection_information)
13
+ allow(FigNewton).to receive(:path_to_migration_assembly)
14
+ allow(FigNewton).to receive(:path_to_migrator_exe)
15
+ allow(FigNewton).to receive(:migration_provider)
16
+ end
17
+
18
+ describe 'initialize' do
19
+
20
+ it "should include profile when provided" do
21
+ expected_profile = "--profile=TestData"
22
+ command = FluentMigratorCommandRunner::OracleMigrationCommand.new({:profile => 'TestData'}).build
23
+ expect(command).to include(expected_profile)
24
+ end
25
+
26
+ it "should not include profile when not provided" do
27
+ command = FluentMigratorCommandRunner::OracleMigrationCommand.new.build
28
+ expect(command).to_not include('--profile')
29
+ end
30
+
31
+ it "should include tag when provided" do
32
+ expected_tag = "--tag Data"
33
+ command = FluentMigratorCommandRunner::OracleMigrationCommand.new({:tag => 'Data'}).build
34
+ expect(command).to include(expected_tag)
35
+ end
36
+
37
+ it "should not include tag when not provided" do
38
+ command = FluentMigratorCommandRunner::OracleMigrationCommand.new.build
39
+ expect(command).to_not include('--tag')
40
+ end
41
+
42
+ it 'should override password' do
43
+ expected_password = 'my_new_password'
44
+ command = FluentMigratorCommandRunner::OracleMigrationCommand.new({:db_password => expected_password}).build
45
+ expect(command).to include(expected_password)
46
+ end
47
+
48
+ it "should allow overriding of default provider" do
49
+ expected_provider = 'mynewprovider'
50
+ allow(FigNewton).to receive(:migration_provider).and_return(expected_provider)
51
+ command = FluentMigratorCommandRunner::OracleMigrationCommand.new.build
52
+ expect(command).to include("--provider #{expected_provider}")
53
+ end
54
+ end
55
+
56
+ describe "build" do
57
+ let(:oracle_command) { FluentMigratorCommandRunner::OracleMigrationCommand.new }
58
+
59
+ it "should include path to migrator" do
60
+ expected = "/My/Path/To/Migrator"
61
+ allow(FigNewton).to receive(:path_to_migrator_exe).and_return(expected)
62
+
63
+ command = oracle_command.build
64
+ expect(command).to include(expected)
65
+ end
66
+
67
+ it "should include default provider" do
68
+ oracle_command.build
69
+ expect(FigNewton).to have_received(:migration_provider).with('oracle')
70
+ end
71
+
72
+ it "should include path to assembly" do
73
+ expected = "--assembly \"/My/Path/To/Assembly\""
74
+ allow(FigNewton).to receive(:path_to_migration_assembly).and_return('/My/Path/To/Assembly')
75
+
76
+ command = oracle_command.build
77
+ expect(command).to include(expected)
78
+ end
79
+
80
+ it "should include task" do
81
+ expected_task = "--task migrate"
82
+ command = oracle_command.build
83
+ expect(command).to include(expected_task)
84
+ end
85
+
86
+ it "should include connection string" do
87
+ command = oracle_command.build()
88
+ expect(command).to include('--conn ')
89
+ end
90
+
91
+ describe "database connection string" do
92
+
93
+ it "should include DATA SOURCE in connection string" do
94
+ expected = 'MYDATA.world'
95
+ @connection_information['database'] = expected
96
+ command = oracle_command.build
97
+ expect(command).to include "DATA SOURCE=#{expected}"
98
+ end
99
+
100
+ it "should include user name in connection string" do
101
+ expected = 'user'
102
+ @connection_information['username'] = expected
103
+ command = oracle_command.build
104
+ expect(command).to include "user id=#{expected}"
105
+ end
106
+
107
+ it "should include password in connection string" do
108
+ expected = 'MyPassword'
109
+ @connection_information['password'] = expected
110
+ command = oracle_command.build
111
+ expect(command).to include "password=#{expected}"
112
+ end
113
+ end
114
+
115
+ end
116
+ end
@@ -0,0 +1,117 @@
1
+ require 'spec_helper'
2
+
3
+ describe FluentMigratorCommandRunner::Rake::Task do
4
+
5
+ after{ Rake.application.clear}
6
+
7
+ context 'defining task' do
8
+ it 'should define rake task named' do
9
+ expected_task_name = 'my_rake_task'
10
+ FluentMigratorCommandRunner::Rake::Task.new(expected_task_name)
11
+ expect(::Rake::Task[expected_task_name]).to_not equal(nil)
12
+ end
13
+ end
14
+
15
+ context 'invoking task' do
16
+ let(:builder){FluentMigratorCommandRunner::CommandBuilder}
17
+ let(:runner){FluentMigratorCommandRunner::Runner}
18
+ before { allow(builder).to receive(:build)}
19
+ before { allow(runner).to receive(:execute)}
20
+ before { allow(FigNewton).to receive(:load)}
21
+ let(:default_task_name){'my_rake_task'}
22
+
23
+
24
+ it 'should migrate the database' do
25
+ FluentMigratorCommandRunner::Rake::Task.new(default_task_name)
26
+ invoke_rake_task
27
+
28
+ expect(builder).to have_received(:build)
29
+ end
30
+
31
+ it 'should execute command' do
32
+ command = "BuildCommmand"
33
+ allow(builder).to receive(:build).and_return(command)
34
+ FluentMigratorCommandRunner::Rake::Task.new(default_task_name)
35
+ invoke_rake_task
36
+
37
+ expect(runner).to have_received(:execute).with(command)
38
+ end
39
+
40
+ it 'should accept profile option' do
41
+ expected_profile = 'my_profile'
42
+ FluentMigratorCommandRunner::Rake::Task.new(default_task_name) do |task|
43
+ task.profile = expected_profile
44
+ end
45
+ invoke_rake_task
46
+
47
+ expect(builder).to have_received(:build).with(hash_including(:profile => expected_profile))
48
+ end
49
+
50
+ it 'should not pass profile option when nil' do
51
+ FluentMigratorCommandRunner::Rake::Task.new(default_task_name)
52
+ invoke_rake_task
53
+
54
+ expect(builder).to_not have_received(:build).with(hash_including(:profile => nil))
55
+ end
56
+
57
+ it 'should accept tag option' do
58
+ expected_tag = 'tag'
59
+ FluentMigratorCommandRunner::Rake::Task.new(default_task_name) do |task|
60
+ task.tag = expected_tag
61
+ end
62
+ invoke_rake_task
63
+
64
+ expect(builder).to have_received(:build).with(hash_including(:tag => expected_tag))
65
+ end
66
+
67
+ it 'should not pass tag option when nil' do
68
+ FluentMigratorCommandRunner::Rake::Task.new(default_task_name)
69
+ invoke_rake_task
70
+
71
+ expect(builder).to_not have_received(:build).with(hash_including(:tag => nil))
72
+ end
73
+
74
+ it 'should accept password argument' do
75
+ expected_password = 'my_password'
76
+ FluentMigratorCommandRunner::Rake::Task.new(default_task_name)
77
+ invoke_rake_task_with_password(expected_password)
78
+
79
+ expect(builder).to have_received(:build).with(hash_including(:db_password => expected_password))
80
+ end
81
+
82
+ it 'should not pass password option when rake is invoked with out password' do
83
+ FluentMigratorCommandRunner::Rake::Task.new(default_task_name)
84
+ invoke_rake_task
85
+
86
+ expect(builder).to_not have_received(:build).with(hash_including(:db_password => nil))
87
+ end
88
+
89
+ it 'should load the fig newton file when option given' do
90
+ FluentMigratorCommandRunner::Rake::Task.new(default_task_name) do |task|
91
+ task.fig_newton_file ='fignewton.yml'
92
+ end
93
+
94
+ invoke_rake_task
95
+ expect(FigNewton).to have_received(:load).with("fignewton.yml")
96
+ end
97
+
98
+ it 'should not load fignewton file' do
99
+ FluentMigratorCommandRunner::Rake::Task.new(default_task_name)
100
+
101
+ invoke_rake_task
102
+ expect(FigNewton).to_not have_received(:load)
103
+ end
104
+
105
+ end
106
+
107
+ private
108
+
109
+ def invoke_rake_task
110
+ ::Rake::Task[default_task_name].invoke
111
+ end
112
+
113
+
114
+ def invoke_rake_task_with_password(password)
115
+ ::Rake::Task[default_task_name].invoke(password)
116
+ end
117
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ describe FluentMigratorCommandRunner::CommandBuilder do
4
+
5
+ let(:runner){FluentMigratorCommandRunner::Runner}
6
+ let(:kernel){Kernel}
7
+ let(:system_error){$?}
8
+
9
+ before { allow(kernel).to receive(:system).and_return(true)}
10
+
11
+ it "should execute command" do
12
+ allow(system_error).to receive(:exitstatus).and_return(0)
13
+ expected_command = "echo Bravo"
14
+ runner.execute(expected_command)
15
+ expect(kernel).to have_received(:system).with(expected_command)
16
+ end
17
+
18
+ context 'fluent migrator failure' do
19
+ it "should raise exception " do
20
+ allow(kernel).to receive(:system)
21
+ allow(system_error).to receive(:exitstatus).and_return(1)
22
+
23
+ expect{runner.execute('')}.to raise_error
24
+ end
25
+
26
+ it "should raise exception when command is invalid" do
27
+ allow(kernel).to receive(:system)
28
+ allow(system_error).to receive(:exitstatus).and_return(127)
29
+ expect{runner.execute('')}.to raise_error()
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,117 @@
1
+ require 'spec_helper'
2
+ require 'socket'
3
+
4
+ describe FluentMigratorCommandRunner::SqlServerMigrationCommand do
5
+
6
+ before do
7
+ @connection_information = {
8
+ 'database' => '',
9
+ 'host' => '',
10
+ 'username' => '',
11
+ 'password' => ''
12
+ }
13
+ allow(FigNewton).to receive(:database).and_return(@connection_information)
14
+ allow(FigNewton).to receive(:path_to_migration_assembly)
15
+ allow(FigNewton).to receive(:path_to_migrator_exe)
16
+ allow(FigNewton).to receive(:migration_provider)
17
+ end
18
+
19
+ describe 'initialize' do
20
+
21
+ it "should include profile when provided" do
22
+ expected_profile = "--profile=TestData"
23
+ command = FluentMigratorCommandRunner::SqlServerMigrationCommand.new({:profile => 'TestData'}).build
24
+ expect(command).to include(expected_profile)
25
+ end
26
+
27
+ it "should not include profile when not provided" do
28
+ command = FluentMigratorCommandRunner::SqlServerMigrationCommand.new.build
29
+ expect(command).to_not include('--profile')
30
+ end
31
+
32
+ it "should include tag when provided" do
33
+ expected_tag = "--tag Data"
34
+ command = FluentMigratorCommandRunner::SqlServerMigrationCommand.new({:tag => 'Data'}).build
35
+ expect(command).to include(expected_tag)
36
+ end
37
+
38
+ it "should not include tag when not provided" do
39
+ command = FluentMigratorCommandRunner::SqlServerMigrationCommand.new.build
40
+ expect(command).to_not include('--tag')
41
+ end
42
+
43
+ it 'should override password' do
44
+ expected_password = 'my_new_password'
45
+ command = FluentMigratorCommandRunner::SqlServerMigrationCommand.new({:db_password => expected_password}).build
46
+ expect(command).to include(expected_password)
47
+ end
48
+
49
+ it "should allow overriding of default provider" do
50
+ expected_provider = 'mynewprovider'
51
+ allow(FigNewton).to receive(:migration_provider).and_return(expected_provider)
52
+ command = FluentMigratorCommandRunner::SqlServerMigrationCommand.new.build
53
+ expect(command).to include("--provider #{expected_provider}")
54
+ end
55
+ end
56
+
57
+ describe "build" do
58
+ let(:oracle_command) { FluentMigratorCommandRunner::SqlServerMigrationCommand.new }
59
+
60
+ it "should include path to migrator" do
61
+ expected = "/My/Path/To/Migrator"
62
+ allow(FigNewton).to receive(:path_to_migrator_exe).and_return(expected)
63
+
64
+ command = oracle_command.build
65
+ expect(command).to include(expected)
66
+ end
67
+
68
+ it "should include default provider" do
69
+ oracle_command.build
70
+ expect(FigNewton).to have_received(:migration_provider).with('oracle')
71
+ end
72
+
73
+ it "should include path to assembly" do
74
+ expected = "--assembly \"/My/Path/To/Assembly\""
75
+ allow(FigNewton).to receive(:path_to_migration_assembly).and_return('/My/Path/To/Assembly')
76
+
77
+ command = oracle_command.build
78
+ expect(command).to include(expected)
79
+ end
80
+
81
+ it "should include task" do
82
+ expected_task = "--task migrate"
83
+ command = oracle_command.build
84
+ expect(command).to include(expected_task)
85
+ end
86
+
87
+ it "should include connection string" do
88
+ command = oracle_command.build()
89
+ expect(command).to include('--conn ')
90
+ end
91
+
92
+ describe "database connection string" do
93
+
94
+ it "should include DATA SOURCE in connection string" do
95
+ expected = 'localhost'
96
+ @connection_information['host'] = expected
97
+ command = oracle_command.build
98
+ expect(command).to include "Server=#{expected}"
99
+ end
100
+
101
+ it "should include user name in connection string" do
102
+ expected = 'user'
103
+ @connection_information['username'] = expected
104
+ command = oracle_command.build
105
+ expect(command).to include "user id=#{expected}"
106
+ end
107
+
108
+ it "should include password in connection string" do
109
+ expected = 'MyPassword'
110
+ @connection_information['password'] = expected
111
+ command = oracle_command.build
112
+ expect(command).to include "password=#{expected}"
113
+ end
114
+ end
115
+
116
+ end
117
+ end
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+
4
+ require 'rspec/mocks'
5
+ require 'rspec'
6
+ require 'fluent-migrator-command-runner'
7
+ require 'rake'
8
+
9
+ # Supress Command Line Warnings
10
+ # TODO: Remove need for these
11
+ RSpec::Mocks.configuration.allow_message_expectations_on_nil = true
12
+ RSpec::Expectations.configuration.on_potential_false_positives = :nothing
metadata CHANGED
@@ -1,30 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-migrator-command-runner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
5
- prerelease:
4
+ version: '0.7'
6
5
  platform: ruby
7
6
  authors:
8
7
  - Mosaic
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-08-22 00:00:00.000000000 Z
11
+ date: 2014-11-11 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: fig_newton
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  description: Build and Execute Fluent Migrator Commands
@@ -33,33 +30,48 @@ executables: []
33
30
  extensions: []
34
31
  extra_rdoc_files: []
35
32
  files:
33
+ - ".gitignore"
34
+ - Gemfile
35
+ - Gemfile.lock
36
+ - README.md
37
+ - Rakefile
38
+ - fluent-migrator-command-runner.gemspec
36
39
  - lib/fluent-migrator-command-runner.rb
37
- - lib/fluent-migrator-command-runner/runner.rb
38
40
  - lib/fluent-migrator-command-runner/command_builder.rb
41
+ - lib/fluent-migrator-command-runner/commands/migration_command.rb
42
+ - lib/fluent-migrator-command-runner/commands/oracle_migration_command.rb
43
+ - lib/fluent-migrator-command-runner/commands/sql_server_migration_command.rb
44
+ - lib/fluent-migrator-command-runner/runner.rb
45
+ - lib/fluent-migrator-command-runner/task.rb
46
+ - lib/fluent-migrator-command-runner/version.rb
47
+ - spec/fluent-migrator-command-runner/command_builder_spec.rb
48
+ - spec/fluent-migrator-command-runner/oracle_migration_command_spec.rb
49
+ - spec/fluent-migrator-command-runner/rake_task_spec.rb
50
+ - spec/fluent-migrator-command-runner/runner_spec.rb
51
+ - spec/fluent-migrator-command-runner/sql_server_migration_command_spec.rb
52
+ - spec/spec_helper.rb
39
53
  homepage: ''
40
54
  licenses:
41
55
  - MIT
56
+ metadata: {}
42
57
  post_install_message:
43
58
  rdoc_options: []
44
59
  require_paths:
45
60
  - lib
46
61
  required_ruby_version: !ruby/object:Gem::Requirement
47
- none: false
48
62
  requirements:
49
- - - ! '>='
63
+ - - ">="
50
64
  - !ruby/object:Gem::Version
51
65
  version: '0'
52
66
  required_rubygems_version: !ruby/object:Gem::Requirement
53
- none: false
54
67
  requirements:
55
- - - ! '>='
68
+ - - ">="
56
69
  - !ruby/object:Gem::Version
57
70
  version: '0'
58
71
  requirements: []
59
72
  rubyforge_project:
60
- rubygems_version: 1.8.28
73
+ rubygems_version: 2.7.6
61
74
  signing_key:
62
- specification_version: 3
63
- summary: ''
75
+ specification_version: 4
76
+ summary: Rake Tasks For Fluent Migrator
64
77
  test_files: []
65
- has_rdoc: