kpm 0.7.2 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
 - data/.gitignore +2 -0
 - data/.rubocop.yml +138 -0
 - data/Gemfile +2 -0
 - data/README.adoc +144 -107
 - data/Rakefile +2 -1
 - data/bin/kpm +4 -2
 - data/kpm.gemspec +11 -8
 - data/lib/kpm.rb +3 -0
 - data/lib/kpm/account.rb +268 -338
 - data/lib/kpm/base_artifact.rb +33 -39
 - data/lib/kpm/base_installer.rb +69 -83
 - data/lib/kpm/blob.rb +29 -0
 - data/lib/kpm/cli.rb +3 -1
 - data/lib/kpm/coordinates.rb +10 -12
 - data/lib/kpm/database.rb +94 -113
 - data/lib/kpm/diagnostic_file.rb +126 -147
 - data/lib/kpm/formatter.rb +76 -48
 - data/lib/kpm/inspector.rb +24 -34
 - data/lib/kpm/installer.rb +53 -46
 - data/lib/kpm/kaui_artifact.rb +4 -3
 - data/lib/kpm/killbill_plugin_artifact.rb +10 -7
 - data/lib/kpm/killbill_server_artifact.rb +13 -12
 - data/lib/kpm/migrations.rb +26 -11
 - data/lib/kpm/nexus_helper/actions.rb +52 -9
 - data/lib/kpm/nexus_helper/cloudsmith_api_calls.rb +83 -0
 - data/lib/kpm/nexus_helper/github_api_calls.rb +70 -0
 - data/lib/kpm/nexus_helper/nexus_api_calls_v2.rb +130 -108
 - data/lib/kpm/nexus_helper/nexus_facade.rb +5 -3
 - data/lib/kpm/plugins_directory.rb +9 -8
 - data/lib/kpm/plugins_directory.yml +14 -173
 - data/lib/kpm/plugins_manager.rb +29 -24
 - data/lib/kpm/sha1_checker.rb +31 -18
 - data/lib/kpm/system.rb +104 -135
 - data/lib/kpm/system_helpers/cpu_information.rb +56 -55
 - data/lib/kpm/system_helpers/disk_space_information.rb +60 -63
 - data/lib/kpm/system_helpers/entropy_available.rb +37 -39
 - data/lib/kpm/system_helpers/memory_information.rb +52 -51
 - data/lib/kpm/system_helpers/os_information.rb +45 -47
 - data/lib/kpm/system_helpers/system_proxy.rb +10 -10
 - data/lib/kpm/tasks.rb +381 -438
 - data/lib/kpm/tenant_config.rb +68 -83
 - data/lib/kpm/tomcat_manager.rb +10 -8
 - data/lib/kpm/trace_logger.rb +18 -16
 - data/lib/kpm/uninstaller.rb +81 -14
 - data/lib/kpm/utils.rb +13 -14
 - data/lib/kpm/version.rb +3 -1
 - data/packaging/Gemfile +2 -0
 - data/pom.xml +211 -40
 - data/spec/kpm/remote/base_artifact_spec.rb +20 -20
 - data/spec/kpm/remote/base_installer_spec.rb +35 -34
 - data/spec/kpm/remote/cloudsmith_api_calls_spec.rb +40 -0
 - data/spec/kpm/remote/github_api_calls_spec.rb +40 -0
 - data/spec/kpm/remote/installer_spec.rb +80 -79
 - data/spec/kpm/remote/kaui_artifact_spec.rb +7 -6
 - data/spec/kpm/remote/killbill_plugin_artifact_spec.rb +25 -30
 - data/spec/kpm/remote/killbill_server_artifact_spec.rb +17 -16
 - data/spec/kpm/remote/migrations_spec.rb +12 -11
 - data/spec/kpm/remote/nexus_facade_spec.rb +32 -28
 - data/spec/kpm/remote/tenant_config_spec.rb +30 -29
 - data/spec/kpm/remote/tomcat_manager_spec.rb +4 -3
 - data/spec/kpm/unit/actions_spec.rb +52 -0
 - data/spec/kpm/unit/base_artifact_spec.rb +19 -18
 - data/spec/kpm/unit/cpu_information_spec.rb +67 -0
 - data/spec/kpm/unit/disk_space_information_spec.rb +47 -0
 - data/spec/kpm/unit/entropy_information_spec.rb +36 -0
 - data/spec/kpm/unit/formatter_spec.rb +163 -0
 - data/spec/kpm/unit/inspector_spec.rb +34 -42
 - data/spec/kpm/unit/installer_spec.rb +7 -6
 - data/spec/kpm/unit/memory_information_spec.rb +102 -0
 - data/spec/kpm/unit/os_information_spec.rb +38 -0
 - data/spec/kpm/unit/plugins_directory_spec.rb +38 -22
 - data/spec/kpm/unit/plugins_manager_spec.rb +62 -66
 - data/spec/kpm/unit/sha1_checker_spec.rb +107 -60
 - data/spec/kpm/unit/uninstaller_spec.rb +118 -72
 - data/spec/kpm/unit_mysql/account_spec.rb +127 -142
 - data/spec/spec_helper.rb +20 -18
 - data/tasks/package.rake +18 -18
 - metadata +42 -22
 
| 
         @@ -1,108 +1,154 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            require 'spec_helper'
         
     | 
| 
       2 
4 
     | 
    
         | 
| 
       3 
5 
     | 
    
         
             
            describe KPM::Uninstaller do
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
      
 6 
     | 
    
         
            +
              let(:destination) { Dir.mktmpdir('uninstaller_spec') }
         
     | 
| 
       5 
7 
     | 
    
         
             
              let(:uninstaller) { KPM::Uninstaller.new(destination) }
         
     | 
| 
       6 
     | 
    
         
            -
              let(:destination) { 'somedir' }
         
     | 
| 
       7 
8 
     | 
    
         | 
| 
       8 
9 
     | 
    
         
             
              let(:plugins_manager_mock) { double(KPM::PluginsManager) }
         
     | 
| 
       9 
10 
     | 
    
         
             
              let(:sha1_checker_mock) { double(KPM::Sha1Checker) }
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              let(:plugin_info) do
         
     | 
| 
      
 13 
     | 
    
         
            +
                {
         
     | 
| 
      
 14 
     | 
    
         
            +
                  plugin_name: plugin_name,
         
     | 
| 
      
 15 
     | 
    
         
            +
                  plugin_key: plugin_key,
         
     | 
| 
      
 16 
     | 
    
         
            +
                  plugin_path: plugin_path,
         
     | 
| 
      
 17 
     | 
    
         
            +
                  versions: [{ version: version1, :is_default => false, :is_disabled => false, :sha1 => nil }, { version: version2, :is_default => true, :is_disabled => false, :sha1 => nil }],
         
     | 
| 
      
 18 
     | 
    
         
            +
                  type: 'java',
         
     | 
| 
      
 19 
     | 
    
         
            +
                  group_id: 'group',
         
     | 
| 
      
 20 
     | 
    
         
            +
                  artifact_id: 'artifact',
         
     | 
| 
      
 21 
     | 
    
         
            +
                  packaging: 'jar',
         
     | 
| 
      
 22 
     | 
    
         
            +
                  classifier: nil
         
     | 
| 
      
 23 
     | 
    
         
            +
                }
         
     | 
| 
      
 24 
     | 
    
         
            +
              end
         
     | 
| 
      
 25 
     | 
    
         
            +
              let(:plugin_name) { 'plugin-name' }
         
     | 
| 
      
 26 
     | 
    
         
            +
              let(:plugin_key) { 'plugin-key' }
         
     | 
| 
      
 27 
     | 
    
         
            +
              let(:plugin_path) { "#{destination}/plugins/java/#{plugin_name}" }
         
     | 
| 
      
 28 
     | 
    
         
            +
              let(:version1) { '1.0' }
         
     | 
| 
      
 29 
     | 
    
         
            +
              let(:version2) { '2.0' }
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
       10 
31 
     | 
    
         
             
              before do
         
     | 
| 
       11 
     | 
    
         
            -
                KPM:: 
     | 
| 
       12 
     | 
    
         
            -
                KPM:: 
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
      
 32 
     | 
    
         
            +
                allow(KPM::PluginsManager).to receive(:new).and_return(plugins_manager_mock)
         
     | 
| 
      
 33 
     | 
    
         
            +
                allow(KPM::Sha1Checker).to receive(:from_file).and_return(sha1_checker_mock)
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                # Calls by the Inspector
         
     | 
| 
      
 36 
     | 
    
         
            +
                allow(plugins_manager_mock).to receive(:get_identifier_key_and_entry) do
         
     | 
| 
      
 37 
     | 
    
         
            +
                  [plugin_key, { 'group_id' => plugin_info[:group_id],
         
     | 
| 
      
 38 
     | 
    
         
            +
                                 'artifact_id' => plugin_info[:artifact_id],
         
     | 
| 
      
 39 
     | 
    
         
            +
                                 'packaging' => plugin_info[:packaging] }]
         
     | 
| 
      
 40 
     | 
    
         
            +
                end
         
     | 
| 
      
 41 
     | 
    
         
            +
                allow(sha1_checker_mock).to receive(:all_sha1) { {} }
         
     | 
| 
       14 
42 
     | 
    
         
             
              end
         
     | 
| 
       15 
43 
     | 
    
         | 
| 
       16 
     | 
    
         
            -
              context ' 
     | 
| 
       17 
     | 
    
         
            -
                 
     | 
| 
      
 44 
     | 
    
         
            +
              context 'utility methods' do
         
     | 
| 
      
 45 
     | 
    
         
            +
                it 'raises an error when directory to delete is invalid' do
         
     | 
| 
      
 46 
     | 
    
         
            +
                  expect do
         
     | 
| 
      
 47 
     | 
    
         
            +
                    uninstaller.send(:validate_dir_for_rmrf, '/home/john')
         
     | 
| 
      
 48 
     | 
    
         
            +
                  end.to raise_error(ArgumentError, 'Path /home/john is not a valid directory')
         
     | 
| 
      
 49 
     | 
    
         
            +
                end
         
     | 
| 
      
 50 
     | 
    
         
            +
                it 'raises an error when directory to delete is not safe' do
         
     | 
| 
      
 51 
     | 
    
         
            +
                  expect do
         
     | 
| 
      
 52 
     | 
    
         
            +
                    uninstaller.send(:validate_dir_for_rmrf, '/tmp')
         
     | 
| 
      
 53 
     | 
    
         
            +
                  end.to raise_error(ArgumentError, "Path /tmp is not a subdirectory of #{destination}")
         
     | 
| 
      
 54 
     | 
    
         
            +
                end
         
     | 
| 
      
 55 
     | 
    
         
            +
              end
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
              context 'when no plugin is installed' do
         
     | 
| 
      
 58 
     | 
    
         
            +
                it 'raises an error when uninstalling a plugin' do
         
     | 
| 
      
 59 
     | 
    
         
            +
                  expect do
         
     | 
| 
      
 60 
     | 
    
         
            +
                    uninstaller.uninstall_plugin(plugin_name)
         
     | 
| 
      
 61 
     | 
    
         
            +
                  end.to raise_error(StandardError, "No plugin with key/name '#{plugin_name}' found installed. Try running 'kpm inspect' for more info")
         
     | 
| 
      
 62 
     | 
    
         
            +
                end
         
     | 
| 
       18 
63 
     | 
    
         | 
| 
       19 
     | 
    
         
            -
                it 'raises  
     | 
| 
       20 
     | 
    
         
            -
                  expect  
     | 
| 
       21 
     | 
    
         
            -
                    uninstaller. 
     | 
| 
       22 
     | 
    
         
            -
                   
     | 
| 
      
 64 
     | 
    
         
            +
                it 'raises an internal error when uninstalling a plugin' do
         
     | 
| 
      
 65 
     | 
    
         
            +
                  expect do
         
     | 
| 
      
 66 
     | 
    
         
            +
                    uninstaller.send(:remove_plugin_versions, plugin_info, true, [version1, version2])
         
     | 
| 
      
 67 
     | 
    
         
            +
                  end.to raise_error(ArgumentError, "Path #{plugin_info[:plugin_path]}/#{version1} is not a valid directory")
         
     | 
| 
       23 
68 
     | 
    
         
             
                end
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
                it 'raises an error when uninstalling a plugin version' do
         
     | 
| 
      
 71 
     | 
    
         
            +
                  expect do
         
     | 
| 
      
 72 
     | 
    
         
            +
                    uninstaller.send(:remove_plugin_version, plugin_info, '3.0')
         
     | 
| 
      
 73 
     | 
    
         
            +
                  end.to raise_error(ArgumentError, "Path #{plugin_info[:plugin_path]}/3.0 is not a valid directory")
         
     | 
| 
      
 74 
     | 
    
         
            +
                end
         
     | 
| 
      
 75 
     | 
    
         
            +
             
     | 
| 
      
 76 
     | 
    
         
            +
                it { expect(uninstaller.send(:categorize_plugins)).to eq({ to_be_deleted: [], to_keep: [] }) }
         
     | 
| 
       24 
77 
     | 
    
         
             
              end
         
     | 
| 
       25 
78 
     | 
    
         | 
| 
       26 
79 
     | 
    
         
             
              context 'when plugin is installed' do
         
     | 
| 
       27 
     | 
    
         
            -
                 
     | 
| 
       28 
     | 
    
         
            -
                   
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
      
 80 
     | 
    
         
            +
                before do
         
     | 
| 
      
 81 
     | 
    
         
            +
                  FileUtils.mkdir_p(plugin_version1_path)
         
     | 
| 
      
 82 
     | 
    
         
            +
                  FileUtils.mkdir_p(plugin_version2_path)
         
     | 
| 
      
 83 
     | 
    
         
            +
                  FileUtils.ln_s(plugin_version2_path, Pathname.new(plugin_path).join('SET_DEFAULT'))
         
     | 
| 
      
 84 
     | 
    
         
            +
                end
         
     | 
| 
      
 85 
     | 
    
         
            +
                let(:plugin_version1_path) { File.join(plugin_path, version1) }
         
     | 
| 
      
 86 
     | 
    
         
            +
                let(:plugin_version2_path) { File.join(plugin_path, version2) }
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
      
 88 
     | 
    
         
            +
                it 'looks up a plugin by name' do
         
     | 
| 
      
 89 
     | 
    
         
            +
                  expect(uninstaller.send(:find_plugin, plugin_name)).to eq(plugin_info)
         
     | 
| 
      
 90 
     | 
    
         
            +
                end
         
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
      
 92 
     | 
    
         
            +
                it 'looks up a plugin by key' do
         
     | 
| 
      
 93 
     | 
    
         
            +
                  expect(uninstaller.send(:find_plugin, plugin_key)).to eq(plugin_info)
         
     | 
| 
       38 
94 
     | 
    
         
             
                end
         
     | 
| 
       39 
95 
     | 
    
         | 
| 
       40 
     | 
    
         
            -
                 
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
     | 
    
         
            -
                let(:plugin_path) { 'plugin-path' }
         
     | 
| 
       43 
     | 
    
         
            -
                let(:version) { '1.0' }
         
     | 
| 
      
 96 
     | 
    
         
            +
                it 'uninstalls if user confirms action' do
         
     | 
| 
      
 97 
     | 
    
         
            +
                  expect(KPM.ui).to receive(:ask).and_return('y')
         
     | 
| 
       44 
98 
     | 
    
         | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
       46 
     | 
    
         
            -
                   
     | 
| 
       47 
     | 
    
         
            -
                   
     | 
| 
       48 
     | 
    
         
            -
                  sha1_checker_mock.should_receive(:remove_entry!).with("group:artifact:jar:#{version}")
         
     | 
| 
      
 99 
     | 
    
         
            +
                  expect(plugins_manager_mock).to receive(:remove_plugin_identifier_key).with(plugin_key)
         
     | 
| 
      
 100 
     | 
    
         
            +
                  expect(sha1_checker_mock).to receive(:remove_entry!).with("group:artifact:jar:#{version1}")
         
     | 
| 
      
 101 
     | 
    
         
            +
                  expect(sha1_checker_mock).to receive(:remove_entry!).with("group:artifact:jar:#{version2}")
         
     | 
| 
       49 
102 
     | 
    
         | 
| 
       50 
     | 
    
         
            -
                  uninstaller.uninstall_plugin(plugin_name). 
     | 
| 
      
 103 
     | 
    
         
            +
                  expect(uninstaller.uninstall_plugin(plugin_name)).to be_truthy
         
     | 
| 
       51 
104 
     | 
    
         
             
                end
         
     | 
| 
       52 
105 
     | 
    
         | 
| 
       53 
     | 
    
         
            -
                it ' 
     | 
| 
       54 
     | 
    
         
            -
                   
     | 
| 
       55 
     | 
    
         
            -
                  plugins_manager_mock.should_receive(:remove_plugin_identifier_key).with(plugin_key)
         
     | 
| 
       56 
     | 
    
         
            -
                  sha1_checker_mock.should_receive(:remove_entry!).with("group:artifact:jar:#{version}")
         
     | 
| 
      
 106 
     | 
    
         
            +
                it 'does nothing if user cancels' do
         
     | 
| 
      
 107 
     | 
    
         
            +
                  expect(KPM.ui).to receive(:ask).and_return('n')
         
     | 
| 
       57 
108 
     | 
    
         | 
| 
       58 
     | 
    
         
            -
                  uninstaller.uninstall_plugin( 
     | 
| 
      
 109 
     | 
    
         
            +
                  expect(uninstaller.uninstall_plugin(plugin_name)).to be_falsey
         
     | 
| 
       59 
110 
     | 
    
         
             
                end
         
     | 
| 
       60 
     | 
    
         
            -
              end
         
     | 
| 
       61 
111 
     | 
    
         | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
       63 
     | 
    
         
            -
             
     | 
| 
       64 
     | 
    
         
            -
                  {
         
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
       66 
     | 
    
         
            -
                          plugin_key: plugin_key,
         
     | 
| 
       67 
     | 
    
         
            -
                          plugin_path: plugin_path,
         
     | 
| 
       68 
     | 
    
         
            -
                          versions: [{version: version1},{version: version2}],
         
     | 
| 
       69 
     | 
    
         
            -
                          group_id: 'group',
         
     | 
| 
       70 
     | 
    
         
            -
                          artifact_id: 'artifact',
         
     | 
| 
       71 
     | 
    
         
            -
                          packaging: 'jar'
         
     | 
| 
       72 
     | 
    
         
            -
                      }
         
     | 
| 
       73 
     | 
    
         
            -
                  }
         
     | 
| 
       74 
     | 
    
         
            -
                end
         
     | 
| 
       75 
     | 
    
         
            -
             
     | 
| 
       76 
     | 
    
         
            -
                let(:plugin_name) { 'plugin-name' }
         
     | 
| 
       77 
     | 
    
         
            -
                let(:plugin_key) { 'plugin-key' }
         
     | 
| 
       78 
     | 
    
         
            -
                let(:plugin_path) { 'plugin-path' }
         
     | 
| 
       79 
     | 
    
         
            -
                let(:version1) { '1.0' }
         
     | 
| 
       80 
     | 
    
         
            -
                let(:version2) { '2.0' }
         
     | 
| 
      
 112 
     | 
    
         
            +
                it 'uninstalls all plugins without confirmation if the force option is given' do
         
     | 
| 
      
 113 
     | 
    
         
            +
                  expect(plugins_manager_mock).to receive(:remove_plugin_identifier_key).with(plugin_key)
         
     | 
| 
      
 114 
     | 
    
         
            +
                  expect(sha1_checker_mock).to receive(:remove_entry!).with("group:artifact:jar:#{version1}")
         
     | 
| 
      
 115 
     | 
    
         
            +
                  expect(sha1_checker_mock).to receive(:remove_entry!).with("group:artifact:jar:#{version2}")
         
     | 
| 
       81 
116 
     | 
    
         | 
| 
       82 
     | 
    
         
            -
             
     | 
| 
       83 
     | 
    
         
            -
             
     | 
| 
      
 117 
     | 
    
         
            +
                  expect(uninstaller.uninstall_plugin(plugin_name, true)).to be_truthy
         
     | 
| 
      
 118 
     | 
    
         
            +
                end
         
     | 
| 
       84 
119 
     | 
    
         | 
| 
       85 
     | 
    
         
            -
             
     | 
| 
       86 
     | 
    
         
            -
                   
     | 
| 
       87 
     | 
    
         
            -
                  sha1_checker_mock.should_receive(:remove_entry!).with("group:artifact:jar:#{version1}")
         
     | 
| 
       88 
     | 
    
         
            -
                  sha1_checker_mock.should_receive(:remove_entry!).with("group:artifact:jar:#{version2}")
         
     | 
| 
      
 120 
     | 
    
         
            +
                it 'uninstalls one version without confirmation if the force option is given' do
         
     | 
| 
      
 121 
     | 
    
         
            +
                  expect(sha1_checker_mock).to receive(:remove_entry!).with("group:artifact:jar:#{version1}")
         
     | 
| 
       89 
122 
     | 
    
         | 
| 
       90 
     | 
    
         
            -
                  uninstaller.uninstall_plugin(plugin_name). 
     | 
| 
      
 123 
     | 
    
         
            +
                  expect(uninstaller.uninstall_plugin(plugin_name, true, version1)).to be_truthy
         
     | 
| 
       91 
124 
     | 
    
         
             
                end
         
     | 
| 
       92 
125 
     | 
    
         | 
| 
       93 
     | 
    
         
            -
                it ' 
     | 
| 
       94 
     | 
    
         
            -
                   
     | 
| 
      
 126 
     | 
    
         
            +
                it 'raises an error when uninstalling a version that does not exist' do
         
     | 
| 
      
 127 
     | 
    
         
            +
                  expect do
         
     | 
| 
      
 128 
     | 
    
         
            +
                    uninstaller.uninstall_plugin(plugin_name, true, '3.0')
         
     | 
| 
      
 129 
     | 
    
         
            +
                  end.to raise_error(ArgumentError)
         
     | 
| 
      
 130 
     | 
    
         
            +
                end
         
     | 
| 
       95 
131 
     | 
    
         | 
| 
       96 
     | 
    
         
            -
             
     | 
| 
      
 132 
     | 
    
         
            +
                it 'categorizes plugins depending on default flag' do
         
     | 
| 
      
 133 
     | 
    
         
            +
                  expect(uninstaller.send(:categorize_plugins)).to eq({ to_be_deleted: [[plugin_info, version1]], to_keep: [[plugin_info, version2]] })
         
     | 
| 
       97 
134 
     | 
    
         
             
                end
         
     | 
| 
       98 
135 
     | 
    
         | 
| 
       99 
     | 
    
         
            -
                it ' 
     | 
| 
       100 
     | 
    
         
            -
                   
     | 
| 
       101 
     | 
    
         
            -
             
     | 
| 
       102 
     | 
    
         
            -
             
     | 
| 
       103 
     | 
    
         
            -
             
     | 
| 
      
 136 
     | 
    
         
            +
                it 'does not cleanup if dry-run is set' do
         
     | 
| 
      
 137 
     | 
    
         
            +
                  expect(uninstaller.uninstall_non_default_plugins(true)).to be_falsey
         
     | 
| 
      
 138 
     | 
    
         
            +
                end
         
     | 
| 
      
 139 
     | 
    
         
            +
             
     | 
| 
      
 140 
     | 
    
         
            +
                it 'does cleanup if dry-run isn\'t set' do
         
     | 
| 
      
 141 
     | 
    
         
            +
                  expect(sha1_checker_mock).to receive(:remove_entry!).with("group:artifact:jar:#{version1}")
         
     | 
| 
      
 142 
     | 
    
         
            +
             
     | 
| 
      
 143 
     | 
    
         
            +
                  plugin_info_copy = Marshal.load(Marshal.dump(plugin_info))
         
     | 
| 
      
 144 
     | 
    
         
            +
                  expect(KPM::Inspector.new.inspect(destination)).to eq({ plugin_name => plugin_info_copy })
         
     | 
| 
      
 145 
     | 
    
         
            +
             
     | 
| 
      
 146 
     | 
    
         
            +
                  expect(uninstaller.uninstall_non_default_plugins(false)).to be_truthy
         
     | 
| 
      
 147 
     | 
    
         
            +
                  plugin_info_copy[:versions].delete_at(0)
         
     | 
| 
      
 148 
     | 
    
         
            +
                  expect(KPM::Inspector.new.inspect(destination)).to eq({ plugin_name => plugin_info_copy })
         
     | 
| 
       104 
149 
     | 
    
         | 
| 
       105 
     | 
    
         
            -
                   
     | 
| 
      
 150 
     | 
    
         
            +
                  # Second time is a no-op
         
     | 
| 
      
 151 
     | 
    
         
            +
                  expect(uninstaller.uninstall_non_default_plugins).to be_falsey
         
     | 
| 
       106 
152 
     | 
    
         
             
                end
         
     | 
| 
       107 
153 
     | 
    
         
             
              end
         
     | 
| 
       108 
154 
     | 
    
         
             
            end
         
     | 
| 
         @@ -1,51 +1,50 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            require 'spec_helper'
         
     | 
| 
       2 
4 
     | 
    
         | 
| 
       3 
5 
     | 
    
         
             
            describe KPM::Account do
         
     | 
| 
       4 
     | 
    
         
            -
              
         
     | 
| 
       5 
6 
     | 
    
         
             
              shared_context 'account' do
         
     | 
| 
       6 
7 
     | 
    
         
             
                include_context 'connection_setup'
         
     | 
| 
       7 
8 
     | 
    
         | 
| 
       8 
     | 
    
         
            -
                let(:account_class)  
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
                 
     | 
| 
       13 
     | 
    
         
            -
                let(: 
     | 
| 
      
 9 
     | 
    
         
            +
                let(:account_class) do
         
     | 
| 
      
 10 
     | 
    
         
            +
                  described_class.new(nil, [killbill_api_key, killbill_api_secret],
         
     | 
| 
      
 11 
     | 
    
         
            +
                                      [killbill_user, killbill_password], url,
         
     | 
| 
      
 12 
     | 
    
         
            +
                                      db_name, [db_username, db_password], db_host, db_port, nil, logger)
         
     | 
| 
      
 13 
     | 
    
         
            +
                end
         
     | 
| 
      
 14 
     | 
    
         
            +
                let(:dummy_account_id) { SecureRandom.uuid }
         
     | 
| 
      
 15 
     | 
    
         
            +
                let(:account_id_invalid) { SecureRandom.uuid }
         
     | 
| 
      
 16 
     | 
    
         
            +
                let(:account_id) { creating_account_with_client }
         
     | 
| 
      
 17 
     | 
    
         
            +
                let(:dummy_data) do
         
     | 
| 
       14 
18 
     | 
    
         
             
                  "-- accounts record_id|id|external_key|email|name|first_name_length|currency|billing_cycle_day_local|parent_account_id|is_payment_delegated_to_parent|payment_method_id|time_zone|locale|address1|address2|company_name|city|state_or_province|country|postal_code|phone|notes|migrated|is_notified_for_invoices|created_date|created_by|updated_date|updated_by|tenant_record_id\n"\
         
     | 
| 
       15 
19 
     | 
    
         
             
                  "5|#{dummy_account_id}|#{dummy_account_id}|willharnet@example.com|Will Harnet||USD|0||||UTC||||Company\\N{VERTICAL LINE}\\N{LINE FEED}Name||||||||false|2017-04-03T15:50:14.000+0000|demo|2017-04-05T15:01:39.000+0000|Killbill::Stripe::PaymentPlugin|2\n"\
         
     | 
| 
       16 
20 
     | 
    
         
             
                  "-- account_history record_id|id|target_record_id|external_key|email|name|first_name_length|currency|billing_cycle_day_local|parent_account_id|payment_method_id|is_payment_delegated_to_parent|time_zone|locale|address1|address2|company_name|city|state_or_province|country|postal_code|phone|notes|migrated|is_notified_for_invoices|change_type|created_by|created_date|updated_by|updated_date|tenant_record_id\n"\
         
     | 
| 
       17 
21 
     | 
    
         
             
                  "3|#{SecureRandom.uuid}|5|#{dummy_account_id}|willharnet@example.com|Will Harnet||USD|0||||UTC||||Company\\N{VERTICAL LINE}\\N{LINE FEED}Name||||||||false|INSERT|demo|2017-04-03T15:50:14.000+0000|demo|2017-04-03T15:50:14.000+0000|2\n"
         
     | 
| 
       18 
     | 
    
         
            -
                 
     | 
| 
       19 
     | 
    
         
            -
                let(:cols_names) {dummy_data.split("\n")[0].split( 
     | 
| 
       20 
     | 
    
         
            -
                let(:cols_data) {dummy_data.split("\n")[1]}
         
     | 
| 
       21 
     | 
    
         
            -
                let(:table_name) {dummy_data.split("\n")[0].split( 
     | 
| 
       22 
     | 
    
         
            -
                let(:obfuscating_marker) {:email}
         
     | 
| 
       23 
     | 
    
         
            -
                let(:mysql_cli) {"mysql --user=#{db_username} --password=#{db_password} --host=#{db_host} --port=#{db_port} "}
         
     | 
| 
       24 
     | 
    
         
            -
                let(:test_ddl) {Dir["#{Dir.pwd}/**/account_test_ddl.sql"][0]}
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
      
 22 
     | 
    
         
            +
                end
         
     | 
| 
      
 23 
     | 
    
         
            +
                let(:cols_names) { dummy_data.split("\n")[0].split(' ')[2] }
         
     | 
| 
      
 24 
     | 
    
         
            +
                let(:cols_data) { dummy_data.split("\n")[1] }
         
     | 
| 
      
 25 
     | 
    
         
            +
                let(:table_name) { dummy_data.split("\n")[0].split(' ')[1] }
         
     | 
| 
      
 26 
     | 
    
         
            +
                let(:obfuscating_marker) { :email }
         
     | 
| 
      
 27 
     | 
    
         
            +
                let(:mysql_cli) { "mysql --user=#{db_username} --password=#{db_password} --host=#{db_host} --port=#{db_port} " }
         
     | 
| 
      
 28 
     | 
    
         
            +
                let(:test_ddl) { Dir["#{Dir.pwd}/**/account_test_ddl.sql"][0] }
         
     | 
| 
       26 
29 
     | 
    
         
             
              end
         
     | 
| 
       27 
30 
     | 
    
         | 
| 
       28 
31 
     | 
    
         
             
              describe '#initialize' do
         
     | 
| 
       29 
     | 
    
         
            -
                include_context 'account' 
     | 
| 
      
 32 
     | 
    
         
            +
                include_context 'account'
         
     | 
| 
       30 
33 
     | 
    
         | 
| 
       31 
34 
     | 
    
         
             
                context 'when creating an instance of account class' do
         
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
35 
     | 
    
         
             
                  it 'when initialized with defaults' do
         
     | 
| 
       34 
36 
     | 
    
         
             
                    expect(described_class.new).to be_an_instance_of(KPM::Account)
         
     | 
| 
       35 
37 
     | 
    
         
             
                  end
         
     | 
| 
       36 
38 
     | 
    
         | 
| 
       37 
39 
     | 
    
         
             
                  it 'when initialized with options' do
         
     | 
| 
       38 
     | 
    
         
            -
                    account_class. 
     | 
| 
      
 40 
     | 
    
         
            +
                    expect(account_class).to be_an_instance_of(KPM::Account)
         
     | 
| 
       39 
41 
     | 
    
         
             
                    expect(account_class.instance_variable_get(:@killbill_api_key)).to eq(killbill_api_key)
         
     | 
| 
       40 
     | 
    
         
            -
                    expect(account_class.instance_variable_get(:@ 
     | 
| 
      
 42 
     | 
    
         
            +
                    expect(account_class.instance_variable_get(:@killbill_api_secret)).to eq(killbill_api_secret)
         
     | 
| 
       41 
43 
     | 
    
         
             
                    expect(account_class.instance_variable_get(:@killbill_user)).to eq(killbill_user)
         
     | 
| 
       42 
44 
     | 
    
         
             
                    expect(account_class.instance_variable_get(:@killbill_password)).to eq(killbill_password)
         
     | 
| 
       43 
45 
     | 
    
         
             
                    expect(account_class.instance_variable_get(:@killbill_url)).to eq(url)
         
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
46 
     | 
    
         
             
                  end
         
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
       47 
47 
     | 
    
         
             
                end
         
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
       49 
48 
     | 
    
         
             
              end
         
     | 
| 
       50 
49 
     | 
    
         | 
| 
       51 
50 
     | 
    
         
             
              # export data tests
         
     | 
| 
         @@ -53,46 +52,38 @@ describe KPM::Account do 
     | 
|
| 
       53 
52 
     | 
    
         
             
                include_context 'account'
         
     | 
| 
       54 
53 
     | 
    
         | 
| 
       55 
54 
     | 
    
         
             
                context 'when fetching account from api' do
         
     | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
       57 
55 
     | 
    
         
             
                  it 'when account id not found' do
         
     | 
| 
       58 
     | 
    
         
            -
                    expect{ account_class.send(:fetch_export_data, account_id_invalid) }.to raise_error(Interrupt, 'Account id not found')
         
     | 
| 
      
 56 
     | 
    
         
            +
                    expect { account_class.send(:fetch_export_data, account_id_invalid) }.to raise_error(Interrupt, 'Account id not found')
         
     | 
| 
       59 
57 
     | 
    
         
             
                  end
         
     | 
| 
       60 
58 
     | 
    
         | 
| 
       61 
59 
     | 
    
         
             
                  it 'when account id found' do
         
     | 
| 
       62 
     | 
    
         
            -
                    account_id = creating_account_with_client
         
     | 
| 
       63 
60 
     | 
    
         
             
                    expect(account_id).to match(/\w{8}(-\w{4}){3}-\w{12}?/)
         
     | 
| 
       64 
     | 
    
         
            -
                    expect{ account_class.send(:fetch_export_data, account_id) }.not_to raise_error 
     | 
| 
      
 61 
     | 
    
         
            +
                    expect { account_class.send(:fetch_export_data, account_id) }.not_to raise_error
         
     | 
| 
       65 
62 
     | 
    
         
             
                    expect(account_class.send(:fetch_export_data, account_id)).to match(account_id)
         
     | 
| 
       66 
63 
     | 
    
         
             
                  end
         
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
64 
     | 
    
         
             
                end
         
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
       70 
65 
     | 
    
         
             
              end
         
     | 
| 
       71 
66 
     | 
    
         | 
| 
       72 
67 
     | 
    
         
             
              describe '#process_export_data' do
         
     | 
| 
       73 
68 
     | 
    
         
             
                include_context 'account'
         
     | 
| 
       74 
69 
     | 
    
         | 
| 
       75 
70 
     | 
    
         
             
                context 'when processing data to export' do
         
     | 
| 
       76 
     | 
    
         
            -
             
     | 
| 
       77 
71 
     | 
    
         
             
                  it 'when column name qty eq column data qty' do
         
     | 
| 
       78 
     | 
    
         
            -
                    expect(account_class.send(:process_export_data, cols_data, table_name, cols_names.split( 
     | 
| 
      
 72 
     | 
    
         
            +
                    expect(account_class.send(:process_export_data, cols_data, table_name, cols_names.split('|')).split('|').size).to eq(cols_names.split('|').size)
         
     | 
| 
       79 
73 
     | 
    
         
             
                  end
         
     | 
| 
       80 
74 
     | 
    
         | 
| 
       81 
75 
     | 
    
         
             
                  it 'when obfuscating data' do
         
     | 
| 
       82 
76 
     | 
    
         
             
                    marker_index = 0
         
     | 
| 
       83 
     | 
    
         
            -
                    cols_names.split( 
     | 
| 
       84 
     | 
    
         
            -
                      if col_name.equal?(obfuscating_marker.to_s)
         
     | 
| 
       85 
     | 
    
         
            -
             
     | 
| 
       86 
     | 
    
         
            -
                      end
         
     | 
| 
      
 77 
     | 
    
         
            +
                    cols_names.split('|').each do |col_name|
         
     | 
| 
      
 78 
     | 
    
         
            +
                      break if col_name.equal?(obfuscating_marker.to_s)
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
       87 
80 
     | 
    
         
             
                      marker_index += 1
         
     | 
| 
       88 
81 
     | 
    
         
             
                    end
         
     | 
| 
       89 
82 
     | 
    
         | 
| 
       90 
     | 
    
         
            -
                    obfuscating_marker_data = account_class.send(:process_export_data, cols_data, table_name, cols_names.split( 
     | 
| 
      
 83 
     | 
    
         
            +
                    obfuscating_marker_data = account_class.send(:process_export_data, cols_data, table_name, cols_names.split('|')).split('|')
         
     | 
| 
       91 
84 
     | 
    
         
             
                    expect(obfuscating_marker_data[marker_index]).to be_nil
         
     | 
| 
       92 
85 
     | 
    
         
             
                  end
         
     | 
| 
       93 
     | 
    
         
            -
             
     | 
| 
       94 
86 
     | 
    
         
             
                end
         
     | 
| 
       95 
     | 
    
         
            -
             
     | 
| 
       96 
87 
     | 
    
         
             
              end
         
     | 
| 
       97 
88 
     | 
    
         | 
| 
       98 
89 
     | 
    
         
             
              describe '#remove_export_data' do
         
     | 
| 
         @@ -101,51 +92,42 @@ describe KPM::Account do 
     | 
|
| 
       101 
92 
     | 
    
         
             
                it 'when obfuscating value' do
         
     | 
| 
       102 
93 
     | 
    
         
             
                  expect(account_class.send(:remove_export_data, table_name, obfuscating_marker.to_s, 'willharnet@example.com')).to be_nil
         
     | 
| 
       103 
94 
     | 
    
         
             
                end
         
     | 
| 
       104 
     | 
    
         
            -
             
     | 
| 
       105 
95 
     | 
    
         
             
              end
         
     | 
| 
       106 
96 
     | 
    
         | 
| 
       107 
97 
     | 
    
         
             
              describe '#export' do
         
     | 
| 
       108 
98 
     | 
    
         
             
                include_context 'account'
         
     | 
| 
       109 
99 
     | 
    
         | 
| 
       110 
100 
     | 
    
         
             
                context 'when exporting data' do
         
     | 
| 
       111 
     | 
    
         
            -
             
     | 
| 
       112 
101 
     | 
    
         
             
                  it 'when file created' do
         
     | 
| 
       113 
     | 
    
         
            -
                    expect(File.exist?(account_class.send(:export, dummy_data))).to  
     | 
| 
      
 102 
     | 
    
         
            +
                    expect(File.exist?(account_class.send(:export, dummy_data))).to be_truthy
         
     | 
| 
       114 
103 
     | 
    
         
             
                  end
         
     | 
| 
       115 
104 
     | 
    
         | 
| 
       116 
105 
     | 
    
         
             
                  it 'when file contains account record' do
         
     | 
| 
       117 
     | 
    
         
            -
                    expect(File.readlines(account_class.send(:export, dummy_data)).grep(/#{table_name}/)).to  
     | 
| 
       118 
     | 
    
         
            -
                    expect(File.readlines(account_class.send(:export, dummy_data)).grep(/#{cols_names}/)).to  
     | 
| 
      
 106 
     | 
    
         
            +
                    expect(File.readlines(account_class.send(:export, dummy_data)).grep(/#{table_name}/)).to be_truthy
         
     | 
| 
      
 107 
     | 
    
         
            +
                    expect(File.readlines(account_class.send(:export, dummy_data)).grep(/#{cols_names}/)).to be_truthy
         
     | 
| 
       119 
108 
     | 
    
         
             
                  end
         
     | 
| 
       120 
     | 
    
         
            -
             
     | 
| 
       121 
109 
     | 
    
         
             
                end
         
     | 
| 
       122 
     | 
    
         
            -
             
     | 
| 
       123 
110 
     | 
    
         
             
              end
         
     | 
| 
       124 
111 
     | 
    
         | 
| 
       125 
112 
     | 
    
         
             
              describe '#export_data' do
         
     | 
| 
       126 
113 
     | 
    
         
             
                include_context 'account'
         
     | 
| 
       127 
114 
     | 
    
         | 
| 
       128 
115 
     | 
    
         
             
                context 'when exporting data; main method' do
         
     | 
| 
       129 
     | 
    
         
            -
             
     | 
| 
       130 
116 
     | 
    
         
             
                  it 'when no account id' do
         
     | 
| 
       131 
     | 
    
         
            -
                    expect{ account_class.export_data }.to raise_error(Interrupt, 'Account id not found')
         
     | 
| 
      
 117 
     | 
    
         
            +
                    expect { account_class.export_data }.to raise_error(Interrupt, 'Account id not found')
         
     | 
| 
       132 
118 
     | 
    
         
             
                  end
         
     | 
| 
       133 
119 
     | 
    
         | 
| 
       134 
120 
     | 
    
         
             
                  it 'when file created' do
         
     | 
| 
       135 
     | 
    
         
            -
                    account_id = creating_account_with_client
         
     | 
| 
       136 
121 
     | 
    
         
             
                    expect(account_id).to match(/\w{8}(-\w{4}){3}-\w{12}?/)
         
     | 
| 
       137 
     | 
    
         
            -
                    expect(File.exist?(account_class.export_data(account_id))).to  
     | 
| 
      
 122 
     | 
    
         
            +
                    expect(File.exist?(account_class.export_data(account_id))).to be_truthy
         
     | 
| 
       138 
123 
     | 
    
         
             
                  end
         
     | 
| 
       139 
124 
     | 
    
         | 
| 
       140 
125 
     | 
    
         
             
                  it 'when file contains account record' do
         
     | 
| 
       141 
     | 
    
         
            -
                    account_id = creating_account_with_client
         
     | 
| 
       142 
126 
     | 
    
         
             
                    expect(account_id).to match(/\w{8}(-\w{4}){3}-\w{12}?/)
         
     | 
| 
       143 
     | 
    
         
            -
                    expect(File.readlines(account_class.export_data(account_id)).grep(/#{table_name}/)).to  
     | 
| 
       144 
     | 
    
         
            -
                    expect(File.readlines(account_class.export_data(account_id)).grep(/#{cols_names}/)).to  
     | 
| 
      
 127 
     | 
    
         
            +
                    expect(File.readlines(account_class.export_data(account_id)).grep(/#{table_name}/)).to be_truthy
         
     | 
| 
      
 128 
     | 
    
         
            +
                    expect(File.readlines(account_class.export_data(account_id)).grep(/#{cols_names}/)).to be_truthy
         
     | 
| 
       145 
129 
     | 
    
         
             
                  end
         
     | 
| 
       146 
     | 
    
         
            -
             
     | 
| 
       147 
130 
     | 
    
         
             
                end
         
     | 
| 
       148 
     | 
    
         
            -
             
     | 
| 
       149 
131 
     | 
    
         
             
              end
         
     | 
| 
       150 
132 
     | 
    
         | 
| 
       151 
133 
     | 
    
         
             
              # import data tests
         
     | 
| 
         @@ -153,14 +135,14 @@ describe KPM::Account do 
     | 
|
| 
       153 
135 
     | 
    
         
             
                include_context 'account'
         
     | 
| 
       154 
136 
     | 
    
         | 
| 
       155 
137 
     | 
    
         
             
                it 'when data delimiter is sniffed as "|"' do
         
     | 
| 
       156 
     | 
    
         
            -
                  open 
     | 
| 
       157 
     | 
    
         
            -
             
     | 
| 
      
 138 
     | 
    
         
            +
                  File.open(dummy_data_file, 'w') do |io|
         
     | 
| 
      
 139 
     | 
    
         
            +
                    io.puts(dummy_data)
         
     | 
| 
       158 
140 
     | 
    
         
             
                  end
         
     | 
| 
       159 
     | 
    
         
            -
             
     | 
| 
      
 141 
     | 
    
         
            +
             
     | 
| 
       160 
142 
     | 
    
         
             
                  expect(account_class.send(:sniff_delimiter, dummy_data_file)).to eq('|')
         
     | 
| 
       161 
143 
     | 
    
         
             
                end
         
     | 
| 
       162 
144 
     | 
    
         
             
              end
         
     | 
| 
       163 
     | 
    
         
            -
             
     | 
| 
      
 145 
     | 
    
         
            +
             
     | 
| 
       164 
146 
     | 
    
         
             
              describe '#fill_empty_column' do
         
     | 
| 
       165 
147 
     | 
    
         
             
                include_context 'account'
         
     | 
| 
       166 
148 
     | 
    
         | 
| 
         @@ -173,7 +155,7 @@ describe KPM::Account do 
     | 
|
| 
       173 
155 
     | 
    
         
             
                include_context 'account'
         
     | 
| 
       174 
156 
     | 
    
         | 
| 
       175 
157 
     | 
    
         
             
                it 'when valid date value' do
         
     | 
| 
       176 
     | 
    
         
            -
                  expect{DateTime.parse(account_class.send(:fix_dates, '2017-04-05T15:01:39.000+0000'))}.not_to raise_error 
     | 
| 
      
 158 
     | 
    
         
            +
                  expect { DateTime.parse(account_class.send(:fix_dates, '2017-04-05T15:01:39.000+0000')) }.not_to raise_error
         
     | 
| 
       177 
159 
     | 
    
         
             
                end
         
     | 
| 
       178 
160 
     | 
    
         | 
| 
       179 
161 
     | 
    
         
             
                it 'when valid date value match YYYY-MM-DD HH:MM:SS' do
         
     | 
| 
         @@ -181,7 +163,7 @@ describe KPM::Account do 
     | 
|
| 
       181 
163 
     | 
    
         
             
                end
         
     | 
| 
       182 
164 
     | 
    
         | 
| 
       183 
165 
     | 
    
         
             
                it 'when invalid date value' do
         
     | 
| 
       184 
     | 
    
         
            -
                  expect{DateTime.parse(account_class.send(:fix_dates, 'JO'))}.to raise_error(ArgumentError)
         
     | 
| 
      
 166 
     | 
    
         
            +
                  expect { DateTime.parse(account_class.send(:fix_dates, 'JO')) }.to raise_error(ArgumentError)
         
     | 
| 
       185 
167 
     | 
    
         
             
                end
         
     | 
| 
       186 
168 
     | 
    
         
             
              end
         
     | 
| 
       187 
169 
     | 
    
         | 
| 
         @@ -196,7 +178,6 @@ describe KPM::Account do 
     | 
|
| 
       196 
178 
     | 
    
         
             
                  it 'when false' do
         
     | 
| 
       197 
179 
     | 
    
         
             
                    expect(account_class.send(:replace_boolean, false)).to eq(0)
         
     | 
| 
       198 
180 
     | 
    
         
             
                  end
         
     | 
| 
       199 
     | 
    
         
            -
             
     | 
| 
       200 
181 
     | 
    
         
             
                end
         
     | 
| 
       201 
182 
     | 
    
         
             
              end
         
     | 
| 
       202 
183 
     | 
    
         | 
| 
         @@ -222,7 +203,6 @@ describe KPM::Account do 
     | 
|
| 
       222 
203 
     | 
    
         
             
                it 'when field is search_key1 and table bus_events_history' do
         
     | 
| 
       223 
204 
     | 
    
         
             
                  expect(account_class.send(:replace_account_record_id, 'bus_events_history', 'search_key1', '1')).to eq(:@account_record_id)
         
     | 
| 
       224 
205 
     | 
    
         
             
                end
         
     | 
| 
       225 
     | 
    
         
            -
             
     | 
| 
       226 
206 
     | 
    
         
             
              end
         
     | 
| 
       227 
207 
     | 
    
         | 
| 
       228 
208 
     | 
    
         
             
              describe '#replace_tenant_record_id' do
         
     | 
| 
         @@ -242,7 +222,6 @@ describe KPM::Account do 
     | 
|
| 
       242 
222 
     | 
    
         
             
                  account_class.instance_variable_set(:@tenant_record_id, 10)
         
     | 
| 
       243 
223 
     | 
    
         
             
                  expect(account_class.send(:replace_tenant_record_id, 'bus_events_history', 'search_key2', '1')).to eq(10)
         
     | 
| 
       244 
224 
     | 
    
         
             
                end
         
     | 
| 
       245 
     | 
    
         
            -
             
     | 
| 
       246 
225 
     | 
    
         
             
              end
         
     | 
| 
       247 
226 
     | 
    
         | 
| 
       248 
227 
     | 
    
         
             
              describe '#replace_uuid' do
         
     | 
| 
         @@ -259,19 +238,39 @@ describe KPM::Account do 
     | 
|
| 
       259 
238 
     | 
    
         
             
                    expect(account_class.send(:replace_uuid, table_name, 'other_id', dummy_account_id)).to eq(dummy_account_id)
         
     | 
| 
       260 
239 
     | 
    
         
             
                  end
         
     | 
| 
       261 
240 
     | 
    
         
             
                end
         
     | 
| 
       262 
     | 
    
         
            -
             
     | 
| 
       263 
241 
     | 
    
         
             
              end
         
     | 
| 
       264 
242 
     | 
    
         | 
| 
       265 
243 
     | 
    
         
             
              describe '#sanitize' do
         
     | 
| 
       266 
244 
     | 
    
         
             
                include_context 'account'
         
     | 
| 
       267 
245 
     | 
    
         | 
| 
       268 
246 
     | 
    
         
             
                it 'when skip payment method' do
         
     | 
| 
       269 
     | 
    
         
            -
                  expect(account_class.send(:sanitize, 'payment_methods', 'plugin_name', 'Payment Method',true)).to eq('__EXTERNAL_PAYMENT__')
         
     | 
| 
      
 247 
     | 
    
         
            +
                  expect(account_class.send(:sanitize, 'payment_methods', 'plugin_name', 'Payment Method', true)).to eq('__EXTERNAL_PAYMENT__')
         
     | 
| 
       270 
248 
     | 
    
         
             
                end
         
     | 
| 
       271 
249 
     | 
    
         
             
                it 'when nothing to sanitize' do
         
     | 
| 
       272 
     | 
    
         
            -
                  expect(account_class.send(:sanitize, table_name, 'id', dummy_account_id,false)).to eq(dummy_account_id)
         
     | 
| 
      
 250 
     | 
    
         
            +
                  expect(account_class.send(:sanitize, table_name, 'id', dummy_account_id, false)).to eq(dummy_account_id)
         
     | 
| 
      
 251 
     | 
    
         
            +
                end
         
     | 
| 
      
 252 
     | 
    
         
            +
              end
         
     | 
| 
      
 253 
     | 
    
         
            +
             
     | 
| 
      
 254 
     | 
    
         
            +
              describe '#sanitize_for_b64_date' do
         
     | 
| 
      
 255 
     | 
    
         
            +
                include_context 'account'
         
     | 
| 
      
 256 
     | 
    
         
            +
             
     | 
| 
      
 257 
     | 
    
         
            +
                let(:non_encoded_b64) do
         
     | 
| 
      
 258 
     | 
    
         
            +
                  # This is my test data
         
     | 
| 
      
 259 
     | 
    
         
            +
                  'This is my test data'
         
     | 
| 
      
 260 
     | 
    
         
            +
                end
         
     | 
| 
      
 261 
     | 
    
         
            +
             
     | 
| 
      
 262 
     | 
    
         
            +
                let(:encoded_b64) do
         
     | 
| 
      
 263 
     | 
    
         
            +
                  # This is my test data
         
     | 
| 
      
 264 
     | 
    
         
            +
                  'VGhpcyBpcyBteSB0ZXN0IGRhdGE='
         
     | 
| 
      
 265 
     | 
    
         
            +
                end
         
     | 
| 
      
 266 
     | 
    
         
            +
             
     | 
| 
      
 267 
     | 
    
         
            +
                it 'when b64 encoded data' do
         
     | 
| 
      
 268 
     | 
    
         
            +
                  expect(account_class.send(:b64_decode_if_needed, encoded_b64).value).to start_with('LOAD_FILE("')
         
     | 
| 
       273 
269 
     | 
    
         
             
                end
         
     | 
| 
       274 
270 
     | 
    
         | 
| 
      
 271 
     | 
    
         
            +
                it 'when b64 non encoded data' do
         
     | 
| 
      
 272 
     | 
    
         
            +
                  expect(account_class.send(:b64_decode_if_needed, non_encoded_b64)).to eq(non_encoded_b64)
         
     | 
| 
      
 273 
     | 
    
         
            +
                end
         
     | 
| 
       275 
274 
     | 
    
         
             
              end
         
     | 
| 
       276 
275 
     | 
    
         | 
| 
       277 
276 
     | 
    
         
             
              describe '#process_import_data' do
         
     | 
| 
         @@ -279,153 +278,139 @@ describe KPM::Account do 
     | 
|
| 
       279 
278 
     | 
    
         | 
| 
       280 
279 
     | 
    
         
             
                context 'when processing data to import' do
         
     | 
| 
       281 
280 
     | 
    
         
             
                  it 'when column name qty eq column data qty without record_id' do
         
     | 
| 
       282 
     | 
    
         
            -
                    account_class.instance_variable_set(:@generate_record_id,true)
         
     | 
| 
       283 
     | 
    
         
            -
                    expect(account_class.send(:process_import_data, cols_data, table_name, cols_names.split('|'), false, []).size).to eq(cols_names.split( 
     | 
| 
      
 281 
     | 
    
         
            +
                    account_class.instance_variable_set(:@generate_record_id, true)
         
     | 
| 
      
 282 
     | 
    
         
            +
                    expect(account_class.send(:process_import_data, cols_data, table_name, cols_names.split('|'), false, []).size).to eq(cols_names.split('|').size - 1)
         
     | 
| 
       284 
283 
     | 
    
         
             
                  end
         
     | 
| 
       285 
284 
     | 
    
         
             
                end
         
     | 
| 
       286 
     | 
    
         
            -
             
     | 
| 
       287 
285 
     | 
    
         
             
              end
         
     | 
| 
       288 
286 
     | 
    
         | 
| 
       289 
287 
     | 
    
         
             
              describe '#import_data' do
         
     | 
| 
       290 
288 
     | 
    
         
             
                include_context 'account'
         
     | 
| 
       291 
289 
     | 
    
         | 
| 
       292 
290 
     | 
    
         
             
                context 'when data to import; main import method' do
         
     | 
| 
       293 
     | 
    
         
            -
                  
         
     | 
| 
       294 
291 
     | 
    
         
             
                  it 'when creating test schema' do
         
     | 
| 
       295 
292 
     | 
    
         
             
                    db = create_test_schema
         
     | 
| 
       296 
293 
     | 
    
         
             
                    expect(db).to eq(db_name)
         
     | 
| 
       297 
294 
     | 
    
         
             
                  end
         
     | 
| 
       298 
     | 
    
         
            -
             
     | 
| 
      
 295 
     | 
    
         
            +
             
     | 
| 
       299 
296 
     | 
    
         
             
                  it 'when importing data with empty file' do
         
     | 
| 
       300 
297 
     | 
    
         
             
                    File.new(dummy_data_file, 'w+').close
         
     | 
| 
       301 
     | 
    
         
            -
                    expect{account_class.import_data(dummy_data_file,nil,true,false,true) }.to raise_error(Interrupt,"Data on #{dummy_data_file} is invalid")
         
     | 
| 
      
 298 
     | 
    
         
            +
                    expect { account_class.import_data(dummy_data_file, nil, true, false, true) }.to raise_error(Interrupt, "Data on #{dummy_data_file} is invalid")
         
     | 
| 
       302 
299 
     | 
    
         
             
                    File.delete(dummy_data_file)
         
     | 
| 
       303 
300 
     | 
    
         
             
                  end
         
     | 
| 
       304 
     | 
    
         
            -
             
     | 
| 
      
 301 
     | 
    
         
            +
             
     | 
| 
       305 
302 
     | 
    
         
             
                  it 'when importing data with no file' do
         
     | 
| 
       306 
     | 
    
         
            -
                    expect{account_class.import_data(dummy_data_file,nil,true,false,true) }.to raise_error(Interrupt, "File #{dummy_data_file} does not exist")
         
     | 
| 
      
 303 
     | 
    
         
            +
                    expect { account_class.import_data(dummy_data_file, nil, true, false, true) }.to raise_error(Interrupt, "File #{dummy_data_file} does not exist")
         
     | 
| 
       307 
304 
     | 
    
         
             
                  end
         
     | 
| 
       308 
     | 
    
         
            -
             
     | 
| 
      
 305 
     | 
    
         
            +
             
     | 
| 
       309 
306 
     | 
    
         
             
                  it 'when importing data with new record_id' do
         
     | 
| 
       310 
     | 
    
         
            -
                    open 
     | 
| 
      
 307 
     | 
    
         
            +
                    File.open(dummy_data_file, 'w') do |io|
         
     | 
| 
       311 
308 
     | 
    
         
             
                      io.puts(dummy_data)
         
     | 
| 
       312 
309 
     | 
    
         
             
                    end
         
     | 
| 
       313 
     | 
    
         
            -
                    expect{account_class.import_data(dummy_data_file,nil,true,false,true) }.not_to raise_error 
     | 
| 
      
 310 
     | 
    
         
            +
                    expect { account_class.import_data(dummy_data_file, nil, true, false, true) }.not_to raise_error
         
     | 
| 
       314 
311 
     | 
    
         | 
| 
       315 
312 
     | 
    
         
             
                    verify_data(dummy_account_id)
         
     | 
| 
       316 
313 
     | 
    
         | 
| 
       317 
     | 
    
         
            -
                    row_count_inserted = delete_statement('accounts','id',dummy_account_id)
         
     | 
| 
      
 314 
     | 
    
         
            +
                    row_count_inserted = delete_statement('accounts', 'id', dummy_account_id)
         
     | 
| 
       318 
315 
     | 
    
         
             
                    expect(row_count_inserted).to eq('1')
         
     | 
| 
       319 
     | 
    
         
            -
                    row_count_inserted = delete_statement('account_history','external_key',dummy_account_id)
         
     | 
| 
      
 316 
     | 
    
         
            +
                    row_count_inserted = delete_statement('account_history', 'external_key', dummy_account_id)
         
     | 
| 
       320 
317 
     | 
    
         
             
                    expect(row_count_inserted).to eq('1')
         
     | 
| 
       321 
318 
     | 
    
         
             
                  end
         
     | 
| 
       322 
319 
     | 
    
         | 
| 
       323 
320 
     | 
    
         
             
                  it 'when importing data reusing record_id' do
         
     | 
| 
       324 
     | 
    
         
            -
                    open 
     | 
| 
      
 321 
     | 
    
         
            +
                    File.open(dummy_data_file, 'w') do |io|
         
     | 
| 
       325 
322 
     | 
    
         
             
                      io.puts(dummy_data)
         
     | 
| 
       326 
323 
     | 
    
         
             
                    end
         
     | 
| 
       327 
     | 
    
         
            -
                    expect{account_class.import_data(dummy_data_file,nil,true,false,false) }.not_to raise_error 
     | 
| 
      
 324 
     | 
    
         
            +
                    expect { account_class.import_data(dummy_data_file, nil, true, false, false) }.not_to raise_error
         
     | 
| 
       328 
325 
     | 
    
         | 
| 
       329 
326 
     | 
    
         
             
                    verify_data(dummy_account_id)
         
     | 
| 
       330 
327 
     | 
    
         | 
| 
       331 
     | 
    
         
            -
                    row_count_inserted = delete_statement('accounts','id',dummy_account_id)
         
     | 
| 
      
 328 
     | 
    
         
            +
                    row_count_inserted = delete_statement('accounts', 'id', dummy_account_id)
         
     | 
| 
       332 
329 
     | 
    
         
             
                    expect(row_count_inserted).to eq('1')
         
     | 
| 
       333 
     | 
    
         
            -
                    row_count_inserted = delete_statement('account_history','external_key',dummy_account_id)
         
     | 
| 
      
 330 
     | 
    
         
            +
                    row_count_inserted = delete_statement('account_history', 'external_key', dummy_account_id)
         
     | 
| 
       334 
331 
     | 
    
         
             
                    expect(row_count_inserted).to eq('1')
         
     | 
| 
       335 
332 
     | 
    
         
             
                  end
         
     | 
| 
       336 
333 
     | 
    
         | 
| 
       337 
334 
     | 
    
         
             
                  it 'when importing data with different tenant_record_id' do
         
     | 
| 
       338 
     | 
    
         
            -
                    open 
     | 
| 
      
 335 
     | 
    
         
            +
                    File.open(dummy_data_file, 'w') do |io|
         
     | 
| 
       339 
336 
     | 
    
         
             
                      io.puts(dummy_data)
         
     | 
| 
       340 
337 
     | 
    
         
             
                    end
         
     | 
| 
       341 
     | 
    
         
            -
                    expect{account_class.import_data(dummy_data_file,10,true,false,true) }.not_to raise_error 
     | 
| 
      
 338 
     | 
    
         
            +
                    expect { account_class.import_data(dummy_data_file, 10, true, false, true) }.not_to raise_error
         
     | 
| 
       342 
339 
     | 
    
         | 
| 
       343 
340 
     | 
    
         
             
                    verify_data(dummy_account_id)
         
     | 
| 
       344 
341 
     | 
    
         | 
| 
       345 
     | 
    
         
            -
                    row_count_inserted = delete_statement('accounts','id',dummy_account_id)
         
     | 
| 
      
 342 
     | 
    
         
            +
                    row_count_inserted = delete_statement('accounts', 'id', dummy_account_id)
         
     | 
| 
       346 
343 
     | 
    
         
             
                    expect(row_count_inserted).to eq('1')
         
     | 
| 
       347 
     | 
    
         
            -
                    row_count_inserted = delete_statement('account_history','external_key',dummy_account_id)
         
     | 
| 
      
 344 
     | 
    
         
            +
                    row_count_inserted = delete_statement('account_history', 'external_key', dummy_account_id)
         
     | 
| 
       348 
345 
     | 
    
         
             
                    expect(row_count_inserted).to eq('1')
         
     | 
| 
       349 
346 
     | 
    
         
             
                  end
         
     | 
| 
       350 
347 
     | 
    
         | 
| 
       351 
348 
     | 
    
         
             
                  it 'when round trip' do
         
     | 
| 
       352 
     | 
    
         
            -
                    open 
     | 
| 
      
 349 
     | 
    
         
            +
                    File.open(dummy_data_file, 'w') do |io|
         
     | 
| 
       353 
350 
     | 
    
         
             
                      io.puts(dummy_data)
         
     | 
| 
       354 
351 
     | 
    
         
             
                    end
         
     | 
| 
       355 
     | 
    
         
            -
                    expect{account_class.import_data(dummy_data_file,10,true,true,true) }.not_to raise_error 
     | 
| 
      
 352 
     | 
    
         
            +
                    expect { account_class.import_data(dummy_data_file, 10, true, true, true) }.not_to raise_error
         
     | 
| 
       356 
353 
     | 
    
         
             
                    new_account_id = account_class.instance_variable_get(:@tables_id)
         
     | 
| 
       357 
354 
     | 
    
         | 
| 
       358 
355 
     | 
    
         
             
                    verify_data(new_account_id['accounts_id'])
         
     | 
| 
       359 
356 
     | 
    
         | 
| 
       360 
     | 
    
         
            -
                    row_count_inserted = delete_statement('accounts','id',new_account_id['accounts_id'])
         
     | 
| 
      
 357 
     | 
    
         
            +
                    row_count_inserted = delete_statement('accounts', 'id', new_account_id['accounts_id'])
         
     | 
| 
       361 
358 
     | 
    
         
             
                    expect(row_count_inserted).to eq('1')
         
     | 
| 
       362 
     | 
    
         
            -
                    row_count_inserted = delete_statement('account_history','external_key',new_account_id['accounts_id'])
         
     | 
| 
      
 359 
     | 
    
         
            +
                    row_count_inserted = delete_statement('account_history', 'external_key', new_account_id['accounts_id'])
         
     | 
| 
       363 
360 
     | 
    
         
             
                    expect(row_count_inserted).to eq('1')
         
     | 
| 
       364 
361 
     | 
    
         
             
                  end
         
     | 
| 
       365 
     | 
    
         
            -
             
     | 
| 
      
 362 
     | 
    
         
            +
             
     | 
| 
       366 
363 
     | 
    
         
             
                  it 'when droping test schema' do
         
     | 
| 
       367 
364 
     | 
    
         
             
                    response = drop_test_schema
         
     | 
| 
       368 
365 
     | 
    
         
             
                    expect(response).to match('')
         
     | 
| 
       369 
366 
     | 
    
         
             
                  end
         
     | 
| 
       370 
     | 
    
         
            -
                 
         
     | 
| 
       371 
367 
     | 
    
         
             
                end
         
     | 
| 
       372 
     | 
    
         
            -
             
         
     | 
| 
       373 
368 
     | 
    
         
             
              end
         
     | 
| 
       374 
     | 
    
         
            -
              
         
     | 
| 
       375 
     | 
    
         
            -
              private 
         
     | 
| 
       376 
     | 
    
         
            -
                def creating_account_with_client
         
     | 
| 
       377 
     | 
    
         
            -
                  if $account_id.nil?
         
     | 
| 
       378 
     | 
    
         
            -
                    KillBillClient.url = url
         
     | 
| 
       379 
     | 
    
         
            -
                    
         
     | 
| 
       380 
     | 
    
         
            -
                    options = {
         
     | 
| 
       381 
     | 
    
         
            -
                      :username => killbill_user,
         
     | 
| 
       382 
     | 
    
         
            -
                      :password => killbill_password,
         
     | 
| 
       383 
     | 
    
         
            -
                      :api_key => killbill_api_key,
         
     | 
| 
       384 
     | 
    
         
            -
                      :api_secret => killbill_api_secrets
         
     | 
| 
       385 
     | 
    
         
            -
                    }
         
     | 
| 
       386 
     | 
    
         
            -
                
         
     | 
| 
       387 
     | 
    
         
            -
                    account = KillBillClient::Model::Account.new
         
     | 
| 
       388 
     | 
    
         
            -
                    account.name = 'KPM Account Test'
         
     | 
| 
       389 
     | 
    
         
            -
                    account.first_name_length = 3
         
     | 
| 
       390 
     | 
    
         
            -
                    account.external_key = SecureRandom.uuid
         
     | 
| 
       391 
     | 
    
         
            -
                    account.currency = 'USD'
         
     | 
| 
       392 
     | 
    
         
            -
                    account = account.create('kpm_account_test', 'kpm_account_test', 'kpm_account_test', options)
         
     | 
| 
       393 
     | 
    
         
            -
                    
         
     | 
| 
       394 
     | 
    
         
            -
                    $account_id = account.account_id
         
     | 
| 
       395 
369 
     | 
    
         | 
| 
       396 
     | 
    
         
            -
             
     | 
| 
       397 
     | 
    
         
            -
             
     | 
| 
       398 
     | 
    
         
            -
             
     | 
| 
       399 
     | 
    
         
            -
                 
     | 
| 
      
 370 
     | 
    
         
            +
              private
         
     | 
| 
      
 371 
     | 
    
         
            +
             
     | 
| 
      
 372 
     | 
    
         
            +
              def creating_account_with_client
         
     | 
| 
      
 373 
     | 
    
         
            +
                KillBillClient.url = url
         
     | 
| 
      
 374 
     | 
    
         
            +
             
     | 
| 
      
 375 
     | 
    
         
            +
                options = {
         
     | 
| 
      
 376 
     | 
    
         
            +
                  username: killbill_user,
         
     | 
| 
      
 377 
     | 
    
         
            +
                  password: killbill_password,
         
     | 
| 
      
 378 
     | 
    
         
            +
                  api_key: killbill_api_key,
         
     | 
| 
      
 379 
     | 
    
         
            +
                  api_secret: killbill_api_secret
         
     | 
| 
      
 380 
     | 
    
         
            +
                }
         
     | 
| 
      
 381 
     | 
    
         
            +
             
     | 
| 
      
 382 
     | 
    
         
            +
                account = KillBillClient::Model::Account.new
         
     | 
| 
      
 383 
     | 
    
         
            +
                account.name = 'KPM Account Test'
         
     | 
| 
      
 384 
     | 
    
         
            +
                account.first_name_length = 3
         
     | 
| 
      
 385 
     | 
    
         
            +
                account.external_key = SecureRandom.uuid
         
     | 
| 
      
 386 
     | 
    
         
            +
                account.currency = 'USD'
         
     | 
| 
      
 387 
     | 
    
         
            +
                account = account.create('kpm_account_test', 'kpm_account_test', 'kpm_account_test', options)
         
     | 
| 
      
 388 
     | 
    
         
            +
             
     | 
| 
      
 389 
     | 
    
         
            +
                account.account_id
         
     | 
| 
      
 390 
     | 
    
         
            +
              end
         
     | 
| 
       400 
391 
     | 
    
         | 
| 
       401 
392 
     | 
    
         
             
              def verify_data(account_id)
         
     | 
| 
       402 
393 
     | 
    
         
             
                response = `#{mysql_cli} #{db_name} -e "select company_name FROM accounts WHERE id = '#{account_id}';" 2>&1`
         
     | 
| 
       403 
394 
     | 
    
         
             
                response_msg = response.split("\n")
         
     | 
| 
       404 
395 
     | 
    
         
             
                company_name = response_msg[response_msg.size - 1]
         
     | 
| 
       405 
396 
     | 
    
         | 
| 
       406 
     | 
    
         
            -
                expect(company_name).to eq( 
     | 
| 
       407 
     | 
    
         
            -
             
     | 
| 
      
 397 
     | 
    
         
            +
                expect(company_name).to eq('Company|\\nName')
         
     | 
| 
      
 398 
     | 
    
         
            +
              end
         
     | 
| 
       408 
399 
     | 
    
         | 
| 
       409 
     | 
    
         
            -
             
     | 
| 
       410 
     | 
    
         
            -
             
     | 
| 
       411 
     | 
    
         
            -
             
     | 
| 
       412 
     | 
    
         
            -
             
     | 
| 
       413 
     | 
    
         
            -
             
     | 
| 
       414 
     | 
    
         
            -
                  row_count_inserted
         
     | 
| 
       415 
     | 
    
         
            -
                end
         
     | 
| 
       416 
     | 
    
         
            -
                
         
     | 
| 
       417 
     | 
    
         
            -
                def create_test_schema
         
     | 
| 
       418 
     | 
    
         
            -
                  response = `#{mysql_cli} -e "CREATE DATABASE IF NOT EXISTS #{db_name};"`
         
     | 
| 
       419 
     | 
    
         
            -
                  response = `#{mysql_cli} #{db_name} < "#{test_ddl}" 2>&1`
         
     | 
| 
       420 
     | 
    
         
            -
                  response_msg = response.split("\n")
         
     | 
| 
       421 
     | 
    
         
            -
                  used_database = response_msg[response_msg.size - 1]
         
     | 
| 
       422 
     | 
    
         
            -
                    
         
     | 
| 
       423 
     | 
    
         
            -
                  used_database
         
     | 
| 
       424 
     | 
    
         
            -
                end
         
     | 
| 
       425 
     | 
    
         
            -
                
         
     | 
| 
       426 
     | 
    
         
            -
                def drop_test_schema
         
     | 
| 
       427 
     | 
    
         
            -
                  response = `#{mysql_cli} -e "DROP DATABASE #{db_name};"`;
         
     | 
| 
       428 
     | 
    
         
            -
                  response
         
     | 
| 
       429 
     | 
    
         
            -
                end
         
     | 
| 
      
 400 
     | 
    
         
            +
              def delete_statement(table_name, column_name, account_id)
         
     | 
| 
      
 401 
     | 
    
         
            +
                response = `#{mysql_cli} #{db_name} -e "DELETE FROM #{table_name} WHERE #{column_name} = '#{account_id}'; SELECT ROW_COUNT();" 2>&1`
         
     | 
| 
      
 402 
     | 
    
         
            +
                response_msg = response.split("\n")
         
     | 
| 
      
 403 
     | 
    
         
            +
                response_msg[response_msg.size - 1]
         
     | 
| 
      
 404 
     | 
    
         
            +
              end
         
     | 
| 
       430 
405 
     | 
    
         | 
| 
       431 
     | 
    
         
            -
             
     | 
| 
      
 406 
     | 
    
         
            +
              def create_test_schema
         
     | 
| 
      
 407 
     | 
    
         
            +
                `#{mysql_cli} -e "CREATE DATABASE IF NOT EXISTS #{db_name};"`
         
     | 
| 
      
 408 
     | 
    
         
            +
                response = `#{mysql_cli} #{db_name} < "#{test_ddl}" 2>&1`
         
     | 
| 
      
 409 
     | 
    
         
            +
                response_msg = response.split("\n")
         
     | 
| 
      
 410 
     | 
    
         
            +
                response_msg[response_msg.size - 1]
         
     | 
| 
      
 411 
     | 
    
         
            +
              end
         
     | 
| 
      
 412 
     | 
    
         
            +
             
     | 
| 
      
 413 
     | 
    
         
            +
              def drop_test_schema
         
     | 
| 
      
 414 
     | 
    
         
            +
                `#{mysql_cli} -e "DROP DATABASE #{db_name};"`
         
     | 
| 
      
 415 
     | 
    
         
            +
              end
         
     | 
| 
      
 416 
     | 
    
         
            +
            end
         
     |