kpm 0.7.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e260780bc136822cf4dca4670b5779054c84d9c3
4
- data.tar.gz: 4ebf213ba82c10eba1177c8afc740dd190fcedde
3
+ metadata.gz: c651b2089fe9f33b3484e82dcdb4471980b6f4ad
4
+ data.tar.gz: 8c746fc62e9332919f0082ffd25b96d450a91d64
5
5
  SHA512:
6
- metadata.gz: 5947555e983f49c7a212ca22c46fc6bed955b3ec23ad995265c081172c1fd68549dcf546c8f52705998f04ff7393d8dbda83539b6e939fff41e8aa7ac8596a00
7
- data.tar.gz: ef3751e24e2e736e549d311ccb129d9c998ae2f7882bf86e3a5ddf77b7ded72ed63383a9544b97fb0bf59a2b68549ade52f119cba3ee47637660f31bae49f996
6
+ metadata.gz: c0da2ef993caf070b2aaa3840e75220c1c9f26f4490bd3a2f5a3c4ca309de9a431e7198600733c2db317e2e2bff557438c447a753ddabc6f08f0c98f21ca4a09
7
+ data.tar.gz: 859900d8b192dd29cdd7f0ecd925b527654e397baac2c0771e7c145876da58ef03ea0508cc4ac5b3fb3595e1017d7820e0203487e28dfbb13aaf1b17c7de05ad
@@ -39,7 +39,7 @@ module KPM
39
39
 
40
40
  DATE_COLUMNS_TO_FIX = ['created_date','updated_date','processing_available_date','effective_date',
41
41
  'boot_date','start_timestamp','last_access_time','payment_date','original_created_date',
42
- 'last_sys_update_date','charged_through_date','bundle_start_date','start_date']
42
+ 'last_sys_update_date','charged_through_date','bundle_start_date','start_date', 'reference_time']
43
43
 
44
44
  # round trip constants duplicate record
45
45
  ROUND_TRIP_EXPORT_IMPORT_MAP = {:accounts => {:id => :accounts_id, :external_key => :accounts_id}, :all => {:account_id => :accounts_id},
@@ -109,6 +109,7 @@ module KPM
109
109
  end
110
110
 
111
111
  def import_data(source_file, tenant_record_id, skip_payment_methods, round_trip_export_import = false, generate_record_id = false)
112
+ source_file = File.expand_path(source_file)
112
113
 
113
114
  @generate_record_id = generate_record_id
114
115
  @tenant_record_id = tenant_record_id
@@ -119,7 +120,7 @@ module KPM
119
120
  end
120
121
 
121
122
  unless File.exist?(source_file)
122
- raise Interrupt, 'Need to specify a valid file'
123
+ raise Interrupt, "File #{source_file} does not exist"
123
124
  end
124
125
 
125
126
  @delimiter = sniff_delimiter(source_file) || @delimiter
@@ -275,6 +276,7 @@ module KPM
275
276
 
276
277
  row = []
277
278
 
279
+ @logger.debug "Processing table_name=#{table_name}, line=#{line}"
278
280
  cols_names.each_with_index do |col_name, index|
279
281
  sanitized_value = sanitize(table_name,col_name,cols[index], skip_payment_methods)
280
282
 
@@ -61,7 +61,7 @@ module KPM
61
61
 
62
62
  def pull_and_put_in_place(logger, coordinate_map, plugin_name, destination_path=nil, skip_top_dir=true, sha1_file=nil, force_download=false, verify_sha1=true, overrides={}, ssl_verify=true)
63
63
  # Build artifact info
64
- artifact_info = artifact_info(logger, coordinate_map, overrides, ssl_verify)
64
+ artifact_info = artifact_info(logger, coordinate_map, sha1_file, force_download, overrides, ssl_verify)
65
65
  artifact_info[:plugin_name] = plugin_name
66
66
  populate_fs_info(artifact_info, destination_path)
67
67
 
@@ -168,19 +168,27 @@ module KPM
168
168
  end
169
169
  end
170
170
 
171
- def artifact_info(logger, coordinate_map, overrides={}, ssl_verify=true)
171
+ def artifact_info(logger, coordinate_map, sha1_file=nil, force_download=false, overrides={}, ssl_verify=true)
172
172
  info = {
173
173
  :skipped => false
174
174
  }
175
175
 
176
+ sha1_checker = sha1_file ? Sha1Checker.from_file(sha1_file) : nil
177
+
176
178
  coordinates = KPM::Coordinates.build_coordinates(coordinate_map)
177
179
  begin
178
180
  nexus_info = nexus_remote(overrides, ssl_verify, logger).get_artifact_info(coordinates)
179
181
  rescue KPM::NexusFacade::ArtifactMalformedException => e
180
- raise StandardError.new("Invalid coordinates #{coordinate_map}")
182
+ raise StandardError.new("Invalid coordinates #{coordinate_map}: #{e}")
181
183
  rescue StandardError => e
182
- logger.warn("Unable to retrieve coordinates #{coordinate_map}")
183
- raise e
184
+ logger.warn("Unable to retrieve coordinates #{coordinate_map}: #{e}")
185
+ cached_coordinates = sha1_checker ? sha1_checker.artifact_info(coordinates) : nil
186
+ if force_download || !cached_coordinates
187
+ raise e
188
+ else
189
+ # Use the cache
190
+ return cached_coordinates
191
+ end
184
192
  end
185
193
 
186
194
  xml = REXML::Document.new(nexus_info)
@@ -189,6 +197,8 @@ module KPM
189
197
  info[:repository_path] = xml.elements['//repositoryPath'].text unless xml.elements['//repositoryPath'].nil?
190
198
  info[:is_tgz] = info[:repository_path].end_with?('.tar.gz') || info[:repository_path].end_with?('.tgz')
191
199
 
200
+ sha1_checker.cache_artifact_info(coordinates, info) if sha1_checker
201
+
192
202
  info
193
203
  end
194
204
 
@@ -223,7 +223,8 @@ module KPM
223
223
 
224
224
  version = specified_version
225
225
  if version.nil? || version == LATEST_VERSION
226
- info = KPM::KillbillServerArtifact.info(kb_version || LATEST_VERSION, @nexus_config, @nexus_ssl_verify)
226
+ sha1_file = "#{bundles_dir}/#{SHA1_FILENAME}"
227
+ info = KPM::KillbillServerArtifact.info(kb_version || LATEST_VERSION, sha1_file, force_download, verify_sha1, @nexus_config, @nexus_ssl_verify)
227
228
  version = info['killbill-platform']
228
229
  end
229
230
  version ||= LATEST_VERSION
@@ -102,7 +102,16 @@ module KPM
102
102
 
103
103
  rows = []
104
104
  table[:rows].each do |row|
105
- rows << row.map{|value| value.is_a?(Symbol) ? value.to_s : "'#{value.to_s.gsub(/['"]/, "'" => "\\'", '"' => '\\"')}'" }.join(",")
105
+ rows << row.map do |value|
106
+ if value.is_a?(Symbol)
107
+ value.to_s
108
+ else
109
+ escaped_value = value.to_s.gsub(/['"]/, "'" => "\\'", '"' => '\\"')
110
+ .gsub('\N{LINE FEED}', "\n")
111
+ .gsub('\N{VERTICAL LINE}', "|")
112
+ "'#{escaped_value}'"
113
+ end
114
+ end.join(",")
106
115
  end
107
116
 
108
117
  value_data = rows.map{|row| "(#{row})" }.join(",")
@@ -66,6 +66,7 @@ module KPM
66
66
 
67
67
  @logger.info "\e[32mDiagnostic data exported under #{zip_file_name} \e[0m"
68
68
 
69
+ return zip_file_name
69
70
  else
70
71
  raise Interrupt, 'Account id or configuration file not found'
71
72
  end
@@ -13,12 +13,14 @@ module KPM
13
13
  versions
14
14
  end
15
15
 
16
- def info(version='LATEST', overrides={}, ssl_verify=true)
16
+ def info(version='LATEST', sha1_file=nil, force_download=false, verify_sha1=true, overrides={}, ssl_verify=true)
17
17
  logger = Logger.new(STDOUT)
18
18
  logger.level = Logger::ERROR
19
19
 
20
20
  version = KPM::Installer.get_kb_latest_stable_version if version == 'LATEST'
21
21
 
22
+ sha1_checker = sha1_file ? Sha1Checker.from_file(sha1_file) : nil
23
+
22
24
  versions = {}
23
25
  Dir.mktmpdir do |dir|
24
26
  # Retrieve the main Kill Bill pom
@@ -29,9 +31,9 @@ module KPM
29
31
  nil,
30
32
  version,
31
33
  dir,
32
- nil,
33
- false,
34
- true,
34
+ sha1_file,
35
+ force_download,
36
+ verify_sha1,
35
37
  overrides,
36
38
  ssl_verify)
37
39
 
@@ -51,9 +53,9 @@ module KPM
51
53
  nil,
52
54
  oss_parent_version,
53
55
  dir,
54
- nil,
55
- false,
56
- true,
56
+ sha1_file,
57
+ force_download,
58
+ verify_sha1,
57
59
  overrides,
58
60
  ssl_verify)
59
61
 
@@ -62,8 +64,19 @@ module KPM
62
64
  %w(killbill-api killbill-plugin-api killbill-commons killbill-platform).each do |property|
63
65
  versions[property] = properties_element.elements["#{property}.version"].text
64
66
  end
67
+
68
+ sha1_checker.cache_killbill_info(version, versions) if sha1_checker
65
69
  end
66
70
  versions
71
+ rescue StandardError => e
72
+ # Network down? Hopefully, we have something in the cache
73
+ cached_version = sha1_checker ? sha1_checker.killbill_info(version) : nil
74
+ if force_download || !cached_version
75
+ raise e
76
+ else
77
+ # Use the cache
78
+ return cached_version
79
+ end
67
80
  end
68
81
  end
69
82
  end
@@ -6,7 +6,12 @@ module KPM
6
6
  def self.all(latest=false)
7
7
  if latest
8
8
  # Look at GitHub (source of truth)
9
- source = URI.parse('https://raw.githubusercontent.com/killbill/killbill-cloud/master/kpm/lib/kpm/plugins_directory.yml').read
9
+ begin
10
+ source = URI.parse('https://raw.githubusercontent.com/killbill/killbill-cloud/master/kpm/lib/kpm/plugins_directory.yml').read
11
+ rescue StandardError
12
+ # Default to built-in version if GitHub isn't accessible
13
+ return self.all(false)
14
+ end
10
15
  YAML.load(source)
11
16
  else
12
17
  source = File.join(File.expand_path(File.dirname(__FILE__)), 'plugins_directory.yml')
@@ -19,7 +24,6 @@ module KPM
19
24
  all(latest).inject({}) { |out, (key, val)| out[key]=val[:versions][kb_version.to_sym] if val[:versions].key?(kb_version.to_sym) ; out}
20
25
  end
21
26
 
22
- # Note: this API is used in Docker images (see kpm_generator.rb, careful when changing it!)
23
27
  def self.lookup(raw_plugin_key, latest=false, raw_kb_version=nil)
24
28
  plugin_key = raw_plugin_key.to_s.downcase
25
29
  plugin = all(latest)[plugin_key.to_sym]
@@ -16,8 +16,9 @@
16
16
  :0.15: 0.2.1
17
17
  :0.16: 0.3.2
18
18
  :0.17: 0.4.10
19
- :0.18: 0.5.10
19
+ :0.18: 0.5.18
20
20
  :0.19: 0.6.0
21
+ :0.20: 0.7.0
21
22
  :require:
22
23
  - :org.killbill.billing.plugin.adyen.merchantAccount
23
24
  - :org.killbill.billing.plugin.adyen.username
@@ -32,7 +33,8 @@
32
33
  :0.17: 4.0.5
33
34
  :0.18: 4.2.5
34
35
  :0.19: 5.1.4
35
- :0.20: 6.0.0
36
+ :0.20: 6.0.1
37
+ :0.21: 7.0.1
36
38
  :avatax:
37
39
  :type: :java
38
40
  :versions:
@@ -41,7 +43,8 @@
41
43
  :0.16: 0.3.0
42
44
  :0.18: 0.4.1
43
45
  :0.19: 0.5.1
44
- :0.20: 0.6.0
46
+ :0.20: 0.6.1
47
+ :0.21: 0.7.0
45
48
  :require:
46
49
  - :org.killbill.billing.plugin.avatax.url
47
50
  - :org.killbill.billing.plugin.avatax.accountNumber
@@ -91,7 +94,7 @@
91
94
  :0.16: 0.2.0
92
95
  :0.18: 0.3.1
93
96
  :0.19: 0.4.0
94
- :0.20: 0.5.0
97
+ :0.20: 0.5.1
95
98
  :firstdata_e4:
96
99
  :type: :ruby
97
100
  :artifact_id: firstdata-e4-plugin
@@ -148,7 +151,7 @@
148
151
  :type: :ruby
149
152
  :versions:
150
153
  :0.16: 0.0.2
151
- :0.18: 0.1.10
154
+ :0.18: 0.1.15
152
155
  :require:
153
156
  - :login
154
157
  - :password
@@ -158,7 +161,8 @@
158
161
  :artifact_id: bridge-plugin
159
162
  :versions:
160
163
  :0.19: 0.0.12
161
- :0.20: 0.1.0
164
+ :0.20: 0.1.2
165
+ :0.21: 0.2.0
162
166
  :payeezy:
163
167
  :type: :java
164
168
  :versions:
@@ -223,7 +227,7 @@
223
227
  :0.17: 4.0.0
224
228
  :0.18: 4.1.1
225
229
  :0.19: 5.0.0
226
- :0.20: 6.0.0
230
+ :0.20: 6.0.1
227
231
  :require:
228
232
  - :api_secret_key
229
233
  :zendesk:
@@ -39,8 +39,36 @@ module KPM
39
39
  save!
40
40
  end
41
41
 
42
+ def artifact_info(coordinates)
43
+ nexus_cache[coordinates]
44
+ end
45
+
46
+ def cache_artifact_info(coordinates, artifact_info)
47
+ # See BaseArtifact#artifact_info
48
+ nexus_keys = [:sha1, :version, :repository_path, :is_tgz]
49
+ nexus_cache[coordinates] = artifact_info ? artifact_info.select { |key,_| nexus_keys.include? key } : nil
50
+ save!
51
+ end
52
+
53
+ def killbill_info(version)
54
+ killbill_cache[version]
55
+ end
56
+
57
+ def cache_killbill_info(version, dependencies)
58
+ killbill_cache[version] = dependencies
59
+ save!
60
+ end
61
+
42
62
  private
43
63
 
64
+ def nexus_cache
65
+ @sha1_config['nexus'] ||= {}
66
+ end
67
+
68
+ def killbill_cache
69
+ @sha1_config['killbill'] ||= {}
70
+ end
71
+
44
72
  def save!
45
73
  Dir.mktmpdir do |tmp_destination_dir|
46
74
  tmp_file = File.join(tmp_destination_dir, File.basename(@sha1_file))
@@ -365,8 +365,11 @@ module KPM
365
365
  say "Fetching info for version #{options[:version]}...\n"
366
366
 
367
367
  versions_info = KillbillServerArtifact.info(options[:version],
368
- options[:overrides],
369
- options[:ssl_verify])
368
+ options[:sha1_file],
369
+ options[:force_download],
370
+ options[:verify_sha1],
371
+ options[:overrides],
372
+ options[:ssl_verify])
370
373
  say "Dependencies for version #{options[:version]}\n " + (versions_info.map {|k,v| "#{k} #{v}"}).join("\n "), :green
371
374
  say "\n\n"
372
375
 
@@ -496,7 +499,6 @@ module KPM
496
499
  :desc => 'Database port'
497
500
  desc 'account', 'export/import accounts'
498
501
  def account
499
- logger.info 'Please wait processing the request!!!'
500
502
  begin
501
503
  config_file = nil
502
504
  if options[:killbill_url] && /https?:\/\/[\S]+/.match(options[:killbill_url]).nil?
@@ -570,7 +572,6 @@ module KPM
570
572
  :desc => 'Killbill URL ex. http://127.0.0.1:8080'
571
573
  desc 'tenant_config', 'export all tenant-level configs.'
572
574
  def tenant_config
573
- logger.info 'Please wait processing the request!!!'
574
575
  begin
575
576
 
576
577
  if options[:killbill_url] && /https?:\/\/[\S]+/.match(options[:killbill_url]).nil?
@@ -657,7 +658,6 @@ module KPM
657
658
  :desc => 'A different folder other than the default bundles directory.'
658
659
  desc 'diagnostic', 'exports and \'zips\' the account data, system, logs and tenant configurations'
659
660
  def diagnostic
660
- logger.info 'Please wait processing the request!!!'
661
661
  begin
662
662
  if options[:account_export] && options[:account_export] == 'account_export'
663
663
  raise Interrupt,'--account_export, please provide a valid account id'
@@ -711,7 +711,7 @@ module KPM
711
711
 
712
712
  def logger
713
713
  logger = ::Logger.new(STDOUT)
714
- logger.level = Logger::INFO
714
+ logger.level = ENV['KPM_DEBUG'] ? Logger::DEBUG : Logger::INFO
715
715
  logger
716
716
  end
717
717
  end
@@ -1,3 +1,3 @@
1
1
  module KPM
2
- VERSION = '0.7.1'
2
+ VERSION = '0.7.2'
3
3
  end
data/pom.xml CHANGED
@@ -26,7 +26,7 @@
26
26
  <groupId>org.kill-bill.billing.installer</groupId>
27
27
  <artifactId>kpm</artifactId>
28
28
  <packaging>pom</packaging>
29
- <version>0.7.1</version>
29
+ <version>0.7.2</version>
30
30
  <name>KPM</name>
31
31
  <url>http://github.com/killbill/killbill-cloud</url>
32
32
  <description>KPM: the Kill Bill Package Manager</description>
@@ -25,6 +25,23 @@ describe KPM::BaseArtifact do
25
25
  end
26
26
  end
27
27
 
28
+ it 'should be able to handle download errors' do
29
+ nexus_down = {:url => 'https://does.not.exist'}
30
+ Dir.mktmpdir do |dir|
31
+ sha1_file = "#{dir}/sha1.yml"
32
+ test_download dir, 'foo-oss.pom.xml', false, false, sha1_file
33
+ # Verify we skip the second time
34
+ test_download dir, 'foo-oss.pom.xml', true, false, sha1_file
35
+ # Verify the download is skipped gracefully when Nexus isn't reachable
36
+ test_download dir, 'foo-oss.pom.xml', true, false, sha1_file, nexus_down
37
+ # Verify the download fails when Nexus isn't reachable and force_download is set
38
+ expect { test_download dir, 'foo-oss.pom.xml', nil, true, sha1_file, nexus_down }.to raise_error(SocketError)
39
+ # Verify the download fails when Nexus isn't reachable and the Nexus cache is empty
40
+ KPM::Sha1Checker.from_file(sha1_file).cache_artifact_info('org.kill-bill.billing:killbill-oss-parent:pom:LATEST', nil)
41
+ expect { test_download dir, 'foo-oss.pom.xml', nil, false, sha1_file, nexus_down }.to raise_error(SocketError)
42
+ end
43
+ end
44
+
28
45
  it 'should be able to download and verify generic .tar.gz artifacts' do
29
46
  # The artifact is not small unfortunately (23.7M)
30
47
  group_id = 'org.kill-bill.billing'
@@ -66,11 +83,10 @@ describe KPM::BaseArtifact do
66
83
  end
67
84
  end
68
85
 
69
-
70
- def test_download(dir, filename=nil, verify_is_skipped=false, force_download=false)
86
+ def test_download(dir, filename=nil, verify_is_skipped=false, force_download=false, sha1_file=nil, overrides={})
71
87
  path = filename.nil? ? dir : dir + '/' + filename
72
88
 
73
- info = KPM::BaseArtifact.pull(@logger, 'org.kill-bill.billing', 'killbill-oss-parent', 'pom', nil, 'LATEST', path, nil, force_download, true, {}, true)
89
+ info = KPM::BaseArtifact.pull(@logger, 'org.kill-bill.billing', 'killbill-oss-parent', 'pom', nil, 'LATEST', path, sha1_file, force_download, true, overrides, true)
74
90
  info[:file_name].should == (filename.nil? ? "killbill-oss-parent-#{info[:version]}.pom" : filename)
75
91
  info[:skipped].should == verify_is_skipped
76
92
  if !info[:skipped]
@@ -67,7 +67,8 @@ describe KPM::Installer do
67
67
  'version' => '1.8.7'
68
68
  },
69
69
  {
70
- 'name' => 'stripe'
70
+ 'name' => 'stripe',
71
+ 'version' => '3.0.3'
71
72
  }]
72
73
  }
73
74
  },
@@ -147,7 +148,7 @@ describe KPM::Installer do
147
148
  plugin_identifiers['stripe']['group_id'].should == 'org.kill-bill.billing.plugin.ruby'
148
149
  plugin_identifiers['stripe']['artifact_id'].should == 'stripe-plugin'
149
150
  plugin_identifiers['stripe']['packaging'].should == 'tar.gz'
150
- plugin_identifiers['stripe']['version'].should >= '4.0.0'
151
+ plugin_identifiers['stripe']['version'].should == '3.0.3'
151
152
  plugin_identifiers['stripe']['language'].should == 'ruby'
152
153
  end
153
154
  end
@@ -30,12 +30,28 @@ describe KPM::KillbillServerArtifact do
30
30
  end
31
31
 
32
32
  it 'should get dependencies information' do
33
- info = KPM::KillbillServerArtifact.info('0.15.9')
34
- info['killbill'].should == '0.15.9'
35
- info['killbill-oss-parent'].should == '0.62'
36
- info['killbill-api'].should == '0.27'
37
- info['killbill-plugin-api'].should == '0.16'
38
- info['killbill-commons'].should == '0.10'
39
- info['killbill-platform'].should == '0.13'
33
+ nexus_down = {:url => 'https://does.not.exist'}
34
+
35
+ Dir.mktmpdir do |dir|
36
+ sha1_file = "#{dir}/sha1.yml"
37
+ info = KPM::KillbillServerArtifact.info('0.15.9', sha1_file)
38
+ info['killbill'].should == '0.15.9'
39
+ info['killbill-oss-parent'].should == '0.62'
40
+ info['killbill-api'].should == '0.27'
41
+ info['killbill-plugin-api'].should == '0.16'
42
+ info['killbill-commons'].should == '0.10'
43
+ info['killbill-platform'].should == '0.13'
44
+ KPM::Sha1Checker.from_file(sha1_file).killbill_info('0.15.9').should == info
45
+
46
+ # Verify the download is skipped gracefully when Nexus isn't reachable
47
+ KPM::KillbillServerArtifact.info('0.15.9', sha1_file, false, nil, nexus_down)
48
+
49
+ # Verify the download fails when Nexus isn't reachable and force_download is set
50
+ expect { KPM::KillbillServerArtifact.info('0.15.9', sha1_file, true, nil, nexus_down) }.to raise_error(SocketError)
51
+
52
+ # Verify the download fails when Nexus isn't reachable and the Nexus cache is empty
53
+ KPM::Sha1Checker.from_file(sha1_file).cache_killbill_info('0.15.9', nil)
54
+ expect { KPM::KillbillServerArtifact.info('0.15.9', sha1_file, false, nil, nexus_down) }.to raise_error(SocketError)
55
+ end
40
56
  end
41
57
  end
@@ -12,9 +12,9 @@ describe KPM::Account do
12
12
  let(:account_id_invalid) {SecureRandom.uuid}
13
13
  let(:dummy_data) {
14
14
  "-- 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
- "5|#{dummy_account_id}|#{dummy_account_id}|willharnet@example.com|Will Harnet||USD|0||||UTC||||||||||||false|2017-04-03T15:50:14.000+0000|demo|2017-04-05T15:01:39.000+0000|Killbill::Stripe::PaymentPlugin|2\n"\
15
+ "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
16
  "-- 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
- "3|#{SecureRandom.uuid}|5|#{dummy_account_id}|willharnet@example.com|Will Harnet||USD|0||||UTC||||||||||||false|INSERT|demo|2017-04-03T15:50:14.000+0000|demo|2017-04-03T15:50:14.000+0000|2\n"
17
+ "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
18
  }
19
19
  let(:cols_names) {dummy_data.split("\n")[0].split(" ")[2]}
20
20
  let(:cols_data) {dummy_data.split("\n")[1]}
@@ -303,7 +303,7 @@ describe KPM::Account do
303
303
  end
304
304
 
305
305
  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,'Need to specify a valid file')
306
+ expect{account_class.import_data(dummy_data_file,nil,true,false,true) }.to raise_error(Interrupt, "File #{dummy_data_file} does not exist")
307
307
  end
308
308
 
309
309
  it 'when importing data with new record_id' do
@@ -312,6 +312,8 @@ describe KPM::Account do
312
312
  end
313
313
  expect{account_class.import_data(dummy_data_file,nil,true,false,true) }.not_to raise_error(Interrupt)
314
314
 
315
+ verify_data(dummy_account_id)
316
+
315
317
  row_count_inserted = delete_statement('accounts','id',dummy_account_id)
316
318
  expect(row_count_inserted).to eq('1')
317
319
  row_count_inserted = delete_statement('account_history','external_key',dummy_account_id)
@@ -324,6 +326,8 @@ describe KPM::Account do
324
326
  end
325
327
  expect{account_class.import_data(dummy_data_file,nil,true,false,false) }.not_to raise_error(Interrupt)
326
328
 
329
+ verify_data(dummy_account_id)
330
+
327
331
  row_count_inserted = delete_statement('accounts','id',dummy_account_id)
328
332
  expect(row_count_inserted).to eq('1')
329
333
  row_count_inserted = delete_statement('account_history','external_key',dummy_account_id)
@@ -336,6 +340,8 @@ describe KPM::Account do
336
340
  end
337
341
  expect{account_class.import_data(dummy_data_file,10,true,false,true) }.not_to raise_error(Interrupt)
338
342
 
343
+ verify_data(dummy_account_id)
344
+
339
345
  row_count_inserted = delete_statement('accounts','id',dummy_account_id)
340
346
  expect(row_count_inserted).to eq('1')
341
347
  row_count_inserted = delete_statement('account_history','external_key',dummy_account_id)
@@ -349,6 +355,8 @@ describe KPM::Account do
349
355
  expect{account_class.import_data(dummy_data_file,10,true,true,true) }.not_to raise_error(Interrupt)
350
356
  new_account_id = account_class.instance_variable_get(:@tables_id)
351
357
 
358
+ verify_data(new_account_id['accounts_id'])
359
+
352
360
  row_count_inserted = delete_statement('accounts','id',new_account_id['accounts_id'])
353
361
  expect(row_count_inserted).to eq('1')
354
362
  row_count_inserted = delete_statement('account_history','external_key',new_account_id['accounts_id'])
@@ -389,8 +397,16 @@ describe KPM::Account do
389
397
 
390
398
  $account_id
391
399
  end
392
-
393
- def delete_statement(table_name,column_name,account_id)
400
+
401
+ def verify_data(account_id)
402
+ response = `#{mysql_cli} #{db_name} -e "select company_name FROM accounts WHERE id = '#{account_id}';" 2>&1`
403
+ response_msg = response.split("\n")
404
+ company_name = response_msg[response_msg.size - 1]
405
+
406
+ expect(company_name).to eq("Company|\\nName")
407
+ end
408
+
409
+ def delete_statement(table_name,column_name,account_id)
394
410
  response = `#{mysql_cli} #{db_name} -e "DELETE FROM #{table_name} WHERE #{column_name} = '#{account_id}'; SELECT ROW_COUNT();" 2>&1`
395
411
  response_msg = response.split("\n")
396
412
  row_count_inserted = response_msg[response_msg.size - 1]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kpm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kill Bill core team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-19 00:00:00.000000000 Z
11
+ date: 2019-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: highline