MuranoCLI 3.2.1.pre.beta.4 → 3.2.1.pre.beta.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +4 -0
  3. data/Gemfile +4 -3
  4. data/HISTORY.md +826 -0
  5. data/Rakefile +415 -47
  6. data/docs/release.rst +275 -0
  7. data/lib/MrMurano/Account.rb +46 -47
  8. data/lib/MrMurano/AccountBase.rb +1 -0
  9. data/lib/MrMurano/Business.rb +183 -44
  10. data/lib/MrMurano/Config.rb +1 -0
  11. data/lib/MrMurano/Exchange.rb +3 -4
  12. data/lib/MrMurano/Solution-Services.rb +25 -7
  13. data/lib/MrMurano/Webservice-File.rb +5 -7
  14. data/lib/MrMurano/commands/business.rb +231 -24
  15. data/lib/MrMurano/commands/child.rb +3 -3
  16. data/lib/MrMurano/commands/element.rb +1 -0
  17. data/lib/MrMurano/commands/settings.rb +7 -0
  18. data/lib/MrMurano/http.rb +1 -3
  19. data/lib/MrMurano/progress.rb +12 -2
  20. data/lib/MrMurano/verbosing.rb +7 -7
  21. data/lib/MrMurano/version.rb +1 -1
  22. data/spec/Account_spec.rb +9 -0
  23. data/spec/ProjectFile_spec.rb +7 -9
  24. data/spec/Webservice-File_spec.rb +2 -1
  25. data/spec/cmd_business_spec.rb +1 -1
  26. data/spec/cmd_common.rb +75 -30
  27. data/spec/cmd_content_spec.rb +3 -1
  28. data/spec/cmd_cors_spec.rb +3 -1
  29. data/spec/cmd_device_spec.rb +7 -5
  30. data/spec/cmd_domain_spec.rb +6 -2
  31. data/spec/cmd_help_spec.rb +13 -6
  32. data/spec/cmd_init_spec.rb +19 -10
  33. data/spec/cmd_keystore_spec.rb +3 -1
  34. data/spec/cmd_link_spec.rb +5 -5
  35. data/spec/cmd_setting_application_spec.rb +13 -16
  36. data/spec/cmd_setting_product_spec.rb +14 -14
  37. data/spec/cmd_status_spec.rb +6 -2
  38. data/spec/cmd_syncdown_application_spec.rb +3 -1
  39. data/spec/cmd_syncdown_both_spec.rb +6 -2
  40. data/spec/cmd_syncdown_unit_spec.rb +3 -0
  41. data/spec/cmd_syncup_spec.rb +8 -4
  42. data/spec/cmd_usage_spec.rb +10 -2
  43. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value 0.webmock +98 -0
  44. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value 1.webmock +98 -0
  45. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value No.webmock +98 -0
  46. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value Yes.webmock +98 -0
  47. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value bob.webmock +72 -0
  48. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value false.webmock +98 -0
  49. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value off.webmock +98 -0
  50. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value on STDIN.webmock +98 -0
  51. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value on.webmock +98 -0
  52. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value true.webmock +98 -0
  53. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a json array blob with STDIN.webmock +98 -0
  54. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a json array blob.webmock +98 -0
  55. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) an array.webmock +98 -0
  56. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) appends an array.webmock +98 -0
  57. data/spec/fixtures/snapshots/murano application setting reads Webservice.cors to a file.webmock +72 -0
  58. data/spec/fixtures/snapshots/murano application setting reads Webservice.cors.webmock +72 -0
  59. data/spec/fixtures/snapshots/murano business list as json.webmock +27 -0
  60. data/spec/fixtures/snapshots/murano business list as table.webmock +27 -0
  61. data/spec/fixtures/snapshots/murano business list fewer fields.webmock +27 -0
  62. data/spec/fixtures/snapshots/murano business list only ids.webmock +27 -0
  63. data/spec/fixtures/snapshots/murano business list output to file.webmock +27 -0
  64. data/spec/fixtures/snapshots/murano business without project help.webmock +9 -0
  65. data/spec/fixtures/snapshots/murano config Needs a key.webmock +9 -0
  66. data/spec/fixtures/snapshots/murano config Reads a key.webmock +9 -0
  67. data/spec/fixtures/snapshots/murano config Removes a key.webmock +9 -0
  68. data/spec/fixtures/snapshots/murano config Sets a key.webmock +9 -0
  69. data/spec/fixtures/snapshots/murano config Sets a user key.webmock +9 -0
  70. data/spec/fixtures/snapshots/murano content life cycle.webmock +144 -0
  71. data/spec/fixtures/snapshots/murano cors sets CORS.webmock +78 -0
  72. data/spec/fixtures/snapshots/murano cors show CORS.webmock +64 -0
  73. data/spec/fixtures/snapshots/murano device activates.webmock +86 -0
  74. data/spec/fixtures/snapshots/murano device enables a batch.webmock +76 -0
  75. data/spec/fixtures/snapshots/murano device enables and lists.webmock +78 -0
  76. data/spec/fixtures/snapshots/murano device writes and reads.webmock +136 -0
  77. data/spec/fixtures/snapshots/murano domain show domain.webmock +101 -0
  78. data/spec/fixtures/snapshots/murano element edit unknown as unknown element.webmock +43 -0
  79. data/spec/fixtures/snapshots/murano element show --help.webmock +9 -0
  80. data/spec/fixtures/snapshots/murano element show as csv.webmock +43 -0
  81. data/spec/fixtures/snapshots/murano element show as default-table.webmock +43 -0
  82. data/spec/fixtures/snapshots/murano element show as json.webmock +43 -0
  83. data/spec/fixtures/snapshots/murano element show as table truncate.webmock +43 -0
  84. data/spec/fixtures/snapshots/murano element show as table wrap.webmock +43 -0
  85. data/spec/fixtures/snapshots/murano element show as yaml.webmock +43 -0
  86. data/spec/fixtures/snapshots/murano element show using ambiguous name.webmock +43 -0
  87. data/spec/fixtures/snapshots/murano element without project usage.webmock +9 -0
  88. data/spec/fixtures/snapshots/murano exchange with project list as json.webmock +59 -0
  89. data/spec/fixtures/snapshots/murano exchange with project list as table.webmock +59 -0
  90. data/spec/fixtures/snapshots/murano exchange with project list fewer fields.webmock +59 -0
  91. data/spec/fixtures/snapshots/murano exchange with project list only ids.webmock +59 -0
  92. data/spec/fixtures/snapshots/murano exchange with project list output to file.webmock +59 -0
  93. data/spec/fixtures/snapshots/murano exchange with project list purchase is already added ID.webmock +83 -0
  94. data/spec/fixtures/snapshots/murano exchange with project list purchase is ambiguous name.webmock +59 -0
  95. data/spec/fixtures/snapshots/murano exchange without project help.webmock +9 -0
  96. data/spec/fixtures/snapshots/murano help using commander as --help.webmock +9 -0
  97. data/spec/fixtures/snapshots/murano help using commander no args.webmock +9 -0
  98. data/spec/fixtures/snapshots/murano help using subshell no args.webmock +9 -0
  99. data/spec/fixtures/snapshots/murano help using subshell with --help.webmock +9 -0
  100. data/spec/fixtures/snapshots/murano init Won't init in HOME (gracefully).webmock +9 -0
  101. data/spec/fixtures/snapshots/murano init in empty directory with existing project.webmock +201 -0
  102. data/spec/fixtures/snapshots/murano init in empty directory without existing project.webmock +193 -0
  103. data/spec/fixtures/snapshots/murano init in existing project directory with ProjectFile.webmock +213 -0
  104. data/spec/fixtures/snapshots/murano init in existing project directory with SolutionFile 0.2.0.webmock +213 -0
  105. data/spec/fixtures/snapshots/murano init in existing project directory with SolutionFile 0.3.0.webmock +213 -0
  106. data/spec/fixtures/snapshots/murano init in existing project directory without ProjectFile.webmock +213 -0
  107. data/spec/fixtures/snapshots/murano keystore can call other commands.webmock +108 -0
  108. data/spec/fixtures/snapshots/murano keystore clearAll.webmock +124 -0
  109. data/spec/fixtures/snapshots/murano keystore deletes.webmock +112 -0
  110. data/spec/fixtures/snapshots/murano keystore gets.webmock +96 -0
  111. data/spec/fixtures/snapshots/murano keystore infos.webmock +96 -0
  112. data/spec/fixtures/snapshots/murano keystore lists.webmock +96 -0
  113. data/spec/fixtures/snapshots/murano link with project links and lists.webmock +149 -0
  114. data/spec/fixtures/snapshots/murano link with project unlinks.webmock +165 -0
  115. data/spec/fixtures/snapshots/murano link without project help.webmock +9 -0
  116. data/spec/fixtures/snapshots/murano link without project subshell vs inline using commander will not list.webmock +27 -0
  117. data/spec/fixtures/snapshots/murano link without project subshell vs inline using subshell will not list.webmock +27 -0
  118. data/spec/fixtures/snapshots/murano logs when project is setup tail log.webmock +9 -0
  119. data/spec/fixtures/snapshots/murano password Lists when no file.webmock +9 -0
  120. data/spec/fixtures/snapshots/murano password deletes a password.webmock +9 -0
  121. data/spec/fixtures/snapshots/murano password sets a password.webmock +9 -0
  122. data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a forced string value on STDIN.webmock +90 -0
  123. data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a forced string value.webmock +90 -0
  124. data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a number value fiftyHalf.webmock +64 -0
  125. data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a number value float 12.67.webmock +90 -0
  126. data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a number value integer 12.webmock +90 -0
  127. data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a number value on STDIN.webmock +90 -0
  128. data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a string value.webmock +90 -0
  129. data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) merges into a dictionary.webmock +90 -0
  130. data/spec/fixtures/snapshots/murano single sync without ProjectFile syncdown.webmock +322 -0
  131. data/spec/fixtures/snapshots/murano status with ProjectFile status.webmock +153 -0
  132. data/spec/fixtures/snapshots/murano status with Solutionfile 0.2.0 status.webmock +153 -0
  133. data/spec/fixtures/snapshots/murano status with Solutionfile 0.3.0 status.webmock +153 -0
  134. data/spec/fixtures/snapshots/murano status without ProjectFile matches file path.webmock +153 -0
  135. data/spec/fixtures/snapshots/murano status without ProjectFile matches route.webmock +153 -0
  136. data/spec/fixtures/snapshots/murano status without ProjectFile status.webmock +153 -0
  137. data/spec/fixtures/snapshots/murano syncdown stubbed without ProjectFile syncdown.webmock +151 -0
  138. data/spec/fixtures/snapshots/murano syncdown without ProjectFile syncdown.webmock +479 -0
  139. data/spec/fixtures/snapshots/murano syncup without ProjectFile syncup.webmock +357 -0
  140. data/spec/fixtures/snapshots/murano token with project list as table.webmock +9 -0
  141. data/spec/fixtures/snapshots/murano token without project help.webmock +9 -0
  142. data/spec/fixtures/snapshots/murano usage show usage.webmock +93 -0
  143. data/spec/spec_helper.rb +9 -3
  144. data/spec/webmock_snapshot.rb +296 -0
  145. metadata +133 -2
data/spec/cmd_common.rb CHANGED
@@ -17,9 +17,12 @@ require 'timeout'
17
17
  require 'tmpdir'
18
18
  require 'webmock/rspec'
19
19
 
20
+ require 'MrMurano/progress'
20
21
  require 'MrMurano/Config'
21
22
  require 'MrMurano/HttpAuthed'
22
23
 
24
+ require 'webmock_snapshot'
25
+
23
26
  # Prevent Commander from registering its at_exit hook.
24
27
  # - Also print warning if spec exits, which rspec doesn't see as wrong.
25
28
  # - Note that this comes before importing Commander.
@@ -29,6 +32,7 @@ $catpured_io = false
29
32
 
30
33
  def capture_stdio
31
34
  return if $catpured_io
35
+ $murcli_wasin = $stdin # (lb): Could probably just use STDIN and skip this global.
32
36
  $murcli_wasout = $stdout
33
37
  $murcli_waserr = $stderr
34
38
  $murcli_wasterm = $terminal
@@ -38,9 +42,11 @@ capture_stdio
38
42
 
39
43
  def restore_stdio
40
44
  return unless $catpured_io
45
+ $stdin = $murcli_wasin
41
46
  $stdout = $murcli_wasout
42
47
  $stderr = $murcli_waserr
43
48
  $terminal = $murcli_wasterm
49
+ $murcli_wasin = nil
44
50
  $murcli_wasout = nil
45
51
  $murcli_waserr = nil
46
52
  $murcli_wasterm = nil
@@ -111,8 +117,10 @@ RSpec.shared_context 'CI_CMD' do
111
117
  args.push '-c', 'fullerror'
112
118
  # The spinner output would make it hard to write expects().
113
119
  args.push '--no-progress'
114
- # Save the token.
115
- args.push '--cache'
120
+
121
+ # FIXME: (lb): Is this necessary? Commenting out for now; will delete later.
122
+ ## Save the token.
123
+ #args.push '--cache'
116
124
 
117
125
  if Gem.win_platform?
118
126
  cmd = args.map do |i|
@@ -170,22 +178,21 @@ RSpec.shared_context 'CI_CMD' do
170
178
  # *** Utility fcns: Murano Solutions management: create/delete/expunge.
171
179
 
172
180
  def murano_solutions_expunge_yes
173
- # (lb): Cannot really use murano_command_run or murano_command_exits
174
- # because we don't know if it'll exit or not.
175
- out, err, status = Open3.capture3(capcmd('murano', 'solutions', 'expunge', '-y'))
181
+ out, err = murano_command_safe('solutions expunge', '-y')
176
182
  expect(out).to \
177
183
  eq('').or \
178
184
  eq("No solutions found\n").or \
179
185
  match(/^Deleted [\d]+ solutions?/)
180
- expect(strip_color(err)).to eq('').or eq("No solutions found\n")
181
- expect(status.exitstatus).to eq(0).or eq(1)
186
+ expect(MrMurano::Progress.strip_color(err)).to eq('').or eq("No solutions found\n")
182
187
  end
183
188
 
184
189
  def project_up(skip_link: false)
185
190
  # Preemptive clean up!
186
191
  murano_solutions_expunge_yes if defined?(PRE_EXPUNGE) && PRE_EXPUNGE
187
192
 
188
- @proj_name_prod = rname('MurCLITestProd')
193
+ @proj_name_prod = @snapshotter.resolve_var(
194
+ 'product.name', rname('MurCLITestProd')
195
+ )
189
196
  # NOTE: Do not use alias, which resolves to base command, but without options.
190
197
  # E.g., use 'solution create', ...; and not 'product create'.
191
198
  out, err = murano_command_run(
@@ -194,7 +201,9 @@ RSpec.shared_context 'CI_CMD' do
194
201
  expect(err).to eq('')
195
202
  expect(out.chomp).to match(/^[a-zA-Z0-9]+$/)
196
203
 
197
- @proj_name_appy = rname('MurCLITestAppy')
204
+ @proj_name_appy = @snapshotter.resolve_var(
205
+ 'application.name', rname('MurCLITestAppy')
206
+ )
198
207
  out, err = murano_command_run(
199
208
  'solution create', '--type', 'application', @proj_name_appy, '--save',
200
209
  )
@@ -241,10 +250,6 @@ RSpec.shared_context 'CI_CMD' do
241
250
  "#{name.downcase}#{Random.new.rand.hash.abs.to_s(16)}"
242
251
  end
243
252
 
244
- def strip_color(str)
245
- str.gsub(/\e\[[;0-9]+m/, '')
246
- end
247
-
248
253
  def strip_fancy(str)
249
254
  # Windows has a complaint about the fancy quotes if you don't encode!, which is
250
255
  #
@@ -279,21 +284,39 @@ RSpec.shared_context 'CI_CMD' do
279
284
  murano_command_runner(cmd, *args, wont_run: true)
280
285
  end
281
286
 
287
+ def murano_command_safe(cmd, *args)
288
+ murano_command_runner(cmd, *args, wont_run: :unknown)
289
+ end
290
+
282
291
  def murano_command_wont_parse(cmd, *args)
283
292
  murano_command_runner(cmd, *args, wont_parse: true)
284
293
  end
285
294
 
286
295
  def murano_command_runner(
287
- cmd, *args, wont_run: false, wont_parse: false, skip_cfg: false
296
+ cmd, *args, wont_run: false, wont_parse: false, skip_cfg: false, stdin_data: nil
288
297
  )
289
- # This is a functional test, so tell WebMock to back off.
290
- allow_net_conn = WebMock::Config.instance.allow_net_connect != false
291
- WebMock.allow_net_connect!
298
+ # DEVS: If you want to set a breakpoint within a command under test,
299
+ # you need to break into byebug before stdio is redirected.
300
+ # Just break, then [c]ontinue, and break again within the test,
301
+ # and then interactive debugging will work. I.e., uncomment this:
302
+ #
303
+ # require 'byebug' ; byebug if true
304
+ #
305
+ # Though really you just need to break once:
306
+ #
307
+ # require 'byebug' ; byebug if !defined?(@@broken)
308
+ # @@broken = true
292
309
 
293
310
  capture_stdio
294
311
  tmpout = StringIO.new
295
312
  tmperr = StringIO.new
296
313
 
314
+ unless stdin_data.nil?
315
+ $stdin = StringIO.new
316
+ $stdin.print(stdin_data)
317
+ $stdin.rewind
318
+ end
319
+
297
320
  # Commander's `say` calls HighLine's $terminal.say, so redirect that, too.
298
321
  hline = HighLine.new($stdin, tmpout)
299
322
  $terminal = hline
@@ -340,7 +363,7 @@ RSpec.shared_context 'CI_CMD' do
340
363
  else
341
364
  runner.old_parse_global_options
342
365
  runner.remove_global_options runner.options, args
343
- if wont_run
366
+ if wont_run == true
344
367
  expect { the_cmd.run(*args) }.to raise_error(SystemExit)
345
368
  else
346
369
  begin
@@ -350,11 +373,23 @@ RSpec.shared_context 'CI_CMD' do
350
373
  restore_stdio
351
374
  raise
352
375
  rescue SystemExit => _err
353
- # This happens if the CLI calls exit, but the test runner was not
354
- # expecting it to exit (because otherwise the test runner would
355
- # have called this method with wont_run: true). So long as our
356
- # $exited_abnormally works as intended, we have nothing to do.
357
- raise
376
+ if wont_run != :unknown
377
+ # This happens if the CLI calls exit, but the test runner was not
378
+ # expecting it to exit (because otherwise the test runner would
379
+ # have called this method with wont_run: true). So long as our
380
+ # $exited_abnormally works as intended, we have nothing to do.
381
+ restore_stdio
382
+ unless tmpout.string.empty?
383
+ puts "ERROR: Unexpected `exit`: out: #{tmpout.string}"
384
+ end
385
+ unless tmperr.string.empty?
386
+ puts "ERROR: Unexpected `exit`: err: #{tmperr.string}"
387
+ end
388
+ if tmpout.string.empty? && tmperr.string.empty?
389
+ puts 'ERROR: Unexpected `exit`: but no stdout nor stderr message'
390
+ end
391
+ raise
392
+ end
358
393
  end
359
394
  end
360
395
  end
@@ -371,12 +406,13 @@ RSpec.shared_context 'CI_CMD' do
371
406
  # $stdout, $stderr = STDOUT, STDERR
372
407
  restore_stdio
373
408
 
374
- WebMock.disable_net_connect! unless allow_net_conn
375
-
376
409
  HighLine.use_color = true
377
410
  Rainbow.enabled = true
378
411
 
379
- [strip_color(tmpout.string), strip_color(tmperr.string)]
412
+ [
413
+ MrMurano::Progress.strip_color(tmpout.string),
414
+ MrMurano::Progress.strip_color(tmperr.string),
415
+ ]
380
416
  end
381
417
 
382
418
  def cmd_verify_help(cmd_name)
@@ -399,13 +435,22 @@ RSpec.shared_context 'CI_CMD' do
399
435
  end
400
436
 
401
437
  # Before: Load Config.
402
- before(:example) do
438
+ before(:example) do |example|
403
439
  $cfg = MrMurano::Config.new
404
440
  $cfg.load
441
+
442
+ # Manage snapshot testing.
443
+ @snapshotter = MrMurano::Snapshot::WebMock.instance
444
+ @snapshotter.reset(example)
445
+ @snapshotter.establish_mocks
446
+ end
447
+
448
+ after(:example) do
449
+ @snapshotter.terminate_mocks
405
450
  end
406
451
 
407
452
  # Around: Make project dir under /tmp.
408
- around(:example) do |ex|
453
+ around(:example) do |example|
409
454
  # Load the byebug library now, before changing directories.
410
455
  # This sets Setting[:histfile]. Within byebug, try `show histfile`.
411
456
  # Make sure this is set now, otherwise, byebug crashes, e.g.,
@@ -419,7 +464,7 @@ RSpec.shared_context 'CI_CMD' do
419
464
  require 'byebug/settings/histfile'
420
465
  _ignored = ::Byebug::HistfileSetting::DEFAULT
421
466
 
422
- $exited_abnormally = ex.example.to_s
467
+ $exited_abnormally = example.example.to_s
423
468
 
424
469
  @testdir = Pathname.new(Dir.pwd).realpath
425
470
  Dir.mktmpdir do |hdir|
@@ -448,7 +493,7 @@ RSpec.shared_context 'CI_CMD' do
448
493
  mk_symlink
449
494
  # Timeout after 300 secs/5 mins.
450
495
  Timeout.timeout(300) do
451
- ex.run
496
+ example.run
452
497
  end
453
498
  rm_symlink
454
499
  end
@@ -14,7 +14,9 @@ RSpec.describe 'murano content', :cmd, :needs_password do
14
14
  include_context 'CI_CMD'
15
15
 
16
16
  before(:example) do
17
- @product_name = rname('contestTest')
17
+ @product_name = @snapshotter.resolve_var(
18
+ 'product.name', rname('contestTest')
19
+ )
18
20
  out, err = murano_command_run(
19
21
  'solution create', '--type', 'product', @product_name, '--save',
20
22
  )
@@ -14,7 +14,9 @@ RSpec.describe 'murano cors', :cmd, :needs_password do
14
14
  include_context 'CI_CMD'
15
15
 
16
16
  before(:example) do
17
- @application_name = rname('corstest')
17
+ @application_name = @snapshotter.resolve_var(
18
+ 'application.name', rname('corstest')
19
+ )
18
20
  out, err = murano_command_run(
19
21
  'solution create', '--type', 'application', @application_name, '--save',
20
22
  )
@@ -13,7 +13,9 @@ RSpec.describe 'murano device', :cmd, :needs_password do
13
13
  include_context 'CI_CMD'
14
14
 
15
15
  before(:example) do
16
- @product_name = rname('deviceTest')
16
+ @product_name = @snapshotter.resolve_var(
17
+ 'product.name', rname('deviceTest')
18
+ )
17
19
  out, err = murano_command_run(
18
20
  'solution create', '--type', 'product', @product_name, '--save',
19
21
  )
@@ -87,10 +89,10 @@ RSpec.describe 'murano device', :cmd, :needs_password do
87
89
 
88
90
  out, err = murano_command_run('syncup', '--resources')
89
91
  expect(out).to eq(
90
- "Adding item state\n" +
91
- "Adding item temperature\n" +
92
- "Adding item uptime\n" +
93
- "Adding item humidity\n" +
92
+ "Adding item state\n" \
93
+ "Adding item temperature\n" \
94
+ "Adding item uptime\n" \
95
+ "Adding item humidity\n" \
94
96
  "Updating remote product resources\n"
95
97
  )
96
98
  expect(err).to eq('')
@@ -13,14 +13,18 @@ RSpec.describe 'murano domain', :cmd, :needs_password do
13
13
  include_context 'CI_CMD'
14
14
 
15
15
  before(:example) do
16
- @product_name = rname('domainTest')
16
+ @product_name = @snapshotter.resolve_var(
17
+ 'product.name', rname('domainTest')
18
+ )
17
19
  out, err = murano_command_run(
18
20
  'solution create', '--type', 'product', @product_name, '--save',
19
21
  )
20
22
  expect(err).to eq('')
21
23
  expect(out.chomp).to match(/^[a-zA-Z0-9]+$/)
22
24
 
23
- @application_name = rname('domainTest')
25
+ @application_name = @snapshotter.resolve_var(
26
+ 'application.name', rname('domainTest')
27
+ )
24
28
  out, err = murano_command_run(
25
29
  'solution create', '--type', 'application', @application_name, '--save',
26
30
  )
@@ -11,6 +11,7 @@ require 'open3'
11
11
  require 'highline/import'
12
12
 
13
13
  require 'cmd_common'
14
+ require 'MrMurano/progress'
14
15
 
15
16
  RSpec.describe 'murano help', :cmd do
16
17
  include_context 'CI_CMD'
@@ -23,7 +24,7 @@ RSpec.describe 'murano help', :cmd do
23
24
  expect(status.exitstatus).to eq(0)
24
25
  end
25
26
 
26
- it 'as --help' do
27
+ it 'with --help' do
27
28
  out, err, status = Open3.capture3(capcmd('murano', '--help'))
28
29
  expect(err).to eq('')
29
30
  expect(out).to_not eq('')
@@ -33,20 +34,26 @@ RSpec.describe 'murano help', :cmd do
33
34
 
34
35
  context 'using commander' do
35
36
  it 'no args' do
36
- #cmd_verify_help('help')
37
- stdout, stderr = murano_command_run('help')
37
+ # (lb): Note that the bare command is really the `help` command, e.g.,
38
+ # So this:
39
+ # out, err, status = Open3.capture3(capcmd('murano'))
40
+ # Or this:
41
+ # $ murano
42
+ # Is the same as this:
43
+ # out, err = murano_command_run('help')
44
+ out, err = murano_command_run('help')
38
45
  # The :help command gets processed by optparse, since we did
39
46
  # not call run!, and optparse looks at $0, which is 'rspec'.
40
- expect(strip_color(stdout)).to start_with(
47
+ expect(MrMurano::Progress.strip_color(out)).to start_with(
41
48
  " NAME:\n\n #{File.basename $PROGRAM_NAME}\n\n DESCRIPTION:\n\n "
42
49
  )
43
- expect(stderr).to eq('')
50
+ expect(err).to eq('')
44
51
  end
45
52
 
46
53
  it 'as --help' do
47
54
  stdout, stderr = murano_command_wont_parse('help', '--help')
48
55
  # See comment above; optparse uses $0, or 'rspec'.
49
- expect(strip_color(stdout)).to start_with(
56
+ expect(MrMurano::Progress.strip_color(stdout)).to start_with(
50
57
  "Usage: #{File.basename $PROGRAM_NAME} [options]\n"
51
58
  )
52
59
  expect(stderr).to eq('')
@@ -150,14 +150,18 @@ RSpec.describe 'murano init', :cmd do
150
150
  before(:example) do
151
151
  murano_solutions_expunge_yes
152
152
 
153
- @applctn_name = rname('initEmptyApp')
153
+ @applctn_name = @snapshotter.resolve_var(
154
+ 'application.name', rname('initEmptyApp')
155
+ )
154
156
  out, err = murano_command_run(
155
157
  'solution create', '--type', 'application', @applctn_name, '--save',
156
158
  )
157
159
  expect(err).to eq('')
158
160
  expect(out.chomp).to match(/^[a-zA-Z0-9]+$/)
159
161
 
160
- @product_name = rname('initEmptyPrd')
162
+ @product_name = @snapshotter.resolve_var(
163
+ 'product.name', rname('initEmptyPrd')
164
+ )
161
165
  out, err = murano_command_run(
162
166
  'solution create', '--type', 'product', @product_name, '--save',
163
167
  )
@@ -209,8 +213,12 @@ RSpec.describe 'murano init', :cmd do
209
213
  context 'without', :needs_password do
210
214
  before(:example) do
211
215
  murano_solutions_expunge_yes
212
- @applctn_name = rname('initCreatingApp')
213
- @product_name = rname('initCreatingPrd')
216
+ @applctn_name = @snapshotter.resolve_var(
217
+ 'application.name', rname('initCreatingApp')
218
+ )
219
+ @product_name = @snapshotter.resolve_var(
220
+ 'product.name', rname('initCreatingPrd')
221
+ )
214
222
  end
215
223
  after(:example) do
216
224
  out, err = murano_command_run(
@@ -235,9 +243,7 @@ RSpec.describe 'murano init', :cmd do
235
243
  #{@applctn_name}
236
244
  #{@product_name}
237
245
  DATA
238
- # 2017-07-05: [lb] added line numbers to use debugger to help maintain this test.
239
- # FIXME/2018-07-26: (lb): Use murano_command_run here? What about stdin_date?
240
- out, err, status = Open3.capture3(capcmd('murano', 'init'), stdin_data: data)
246
+ out, err = murano_command_run('init', stdin_data: data)
241
247
  expecting = expected_response_when_ids_found_in_config(
242
248
  self,
243
249
  has_no_solutions: true,
@@ -279,7 +285,6 @@ RSpec.describe 'murano init', :cmd do
279
285
  # "\n", # 30
280
286
  #])
281
287
  expect(err).to eq('')
282
- expect(status.exitstatus).to eq(0)
283
288
 
284
289
  expect(File.directory?('.murano')).to be true
285
290
  expect(File.exist?('.murano/config')).to be true
@@ -301,14 +306,18 @@ RSpec.describe 'murano init', :cmd do
301
306
  FileUtils.cp_r(File.join(@testdir, 'spec/fixtures/syncable_content/.'), '.')
302
307
  FileUtils.move('assets', 'files')
303
308
 
304
- @applctn_name = rname('initEmptyApp')
309
+ @applctn_name = @snapshotter.resolve_var(
310
+ 'application.name', rname('initEmptyApp')
311
+ )
305
312
  out, err = murano_command_run(
306
313
  'solution create', '--type', 'application', @applctn_name, '--save',
307
314
  )
308
315
  expect(err).to eq('')
309
316
  expect(out.chomp).to match(/^[a-zA-Z0-9]+$/)
310
317
 
311
- @product_name = rname('initEmptyPrd')
318
+ @product_name = @snapshotter.resolve_var(
319
+ 'product.name', rname('initEmptyPrd')
320
+ )
312
321
  out, err = murano_command_run(
313
322
  'solution create', '--type', 'product', @product_name, '--save',
314
323
  )
@@ -16,7 +16,9 @@ RSpec.describe 'murano keystore', :cmd, :needs_password do
16
16
  before(:example) do
17
17
  murano_solutions_expunge_yes
18
18
 
19
- @product_name = rname('keystoreTest')
19
+ @product_name = @snapshotter.resolve_var(
20
+ 'product.name', rname('keystoreTest')
21
+ )
20
22
  out, err = murano_command_run(
21
23
  'solution create', '--type', 'application', @product_name, '--save',
22
24
  )
@@ -10,6 +10,7 @@ require 'open3'
10
10
 
11
11
  require 'cmd_common'
12
12
  require 'MrMurano/Config'
13
+ require 'MrMurano/progress'
13
14
  require 'MrMurano/commands/link'
14
15
 
15
16
  RSpec.describe 'murano link', :cmd, :needs_password do
@@ -26,11 +27,10 @@ RSpec.describe 'murano link', :cmd, :needs_password do
26
27
  context 'subshell vs inline' do
27
28
  context 'using subshell' do
28
29
  it 'will not list' do
29
- out, err, status = Open3.capture3(capcmd('murano', 'link', 'list'))
30
- expect(strip_color(out)).to eq(MrMurano::Config::INVALID_PROJECT_HINT + "\n")
31
- expecting = %(The "link list" command only works in a Murano project.\n)
32
- expect(strip_color(err)).to eq(expecting)
33
- expect(status.exitstatus).to eq(1)
30
+ out, err = murano_command_exits('link list')
31
+ expect(out).to eq('')
32
+ expecting = %(No applications found\nNo service links found\n)
33
+ expect(MrMurano::Progress.strip_color(err)).to eq(expecting)
34
34
  end
35
35
  end
36
36
 
@@ -17,7 +17,9 @@ RSpec.describe 'murano application setting', :cmd, :needs_password do
17
17
  before(:example) do
18
18
  murano_solutions_expunge_yes
19
19
 
20
- @product_name = rname('settingtest')
20
+ @product_name = @snapshotter.resolve_var(
21
+ 'product.name', rname('settingtest')
22
+ )
21
23
  out, err = murano_command_run(
22
24
  'solution create', '--type', 'application', @product_name, '--save',
23
25
  )
@@ -57,9 +59,9 @@ RSpec.describe 'murano application setting', :cmd, :needs_password do
57
59
  expect(err).to eq('')
58
60
  end
59
61
  # {'origin'=>true,
60
- # 'methods'=>['HEAD', 'GET', 'POST', 'PUT', 'DELETE', 'OPTIONS', 'PATCH'],
61
- # 'headers'=>['Content-Type', 'Cookie', 'Authorization'],
62
- # 'credentials'=>true}
62
+ # 'methods'=>['HEAD', 'GET', 'POST', 'PUT', 'DELETE', 'OPTIONS', 'PATCH'],
63
+ # 'headers'=>['Content-Type', 'Cookie', 'Authorization'],
64
+ # 'credentials'=>true}
63
65
 
64
66
  context 'a bool value' do
65
67
  it 'Yes', :club_10s do
@@ -207,13 +209,12 @@ RSpec.describe 'murano application setting', :cmd, :needs_password do
207
209
  end
208
210
 
209
211
  it 'on STDIN', :club_10s do
210
- # FIXME: (lb): Replace capcmd with murano_command_run (need to handle stdin_data).
211
- out, err, status = Open3.capture3(capcmd(
212
- 'murano', 'setting', 'write', 'Webservice.cors', 'origin', '--bool'
213
- ), stdin_data: 'true')
212
+ out, err = murano_command_run(
213
+ 'setting write', 'Webservice.cors', 'origin', '--bool',
214
+ stdin_data: 'true',
215
+ )
214
216
  expect(err).to eq('')
215
217
  expect(out).to eq('')
216
- expect(status.exitstatus).to eq(0)
217
218
 
218
219
  out, err = murano_command_run(
219
220
  'setting read', 'Webservice.cors', '-c', 'outformat=json',
@@ -244,16 +245,12 @@ RSpec.describe 'murano application setting', :cmd, :needs_password do
244
245
  end
245
246
 
246
247
  it 'a json array blob with STDIN', :club_10s do
247
- # FIXME: (lb): Replace capcmd with murano_command_run (need to handle stdin_data).
248
- out, err, status = Open3.capture3(
249
- capcmd(
250
- 'murano', 'setting', 'write', 'Webservice.cors', 'headers', '--json',
251
- ),
252
- stdin_data: '["fidget", "forgotten", "tokens"]'
248
+ out, err = murano_command_run(
249
+ 'setting write', 'Webservice.cors', 'headers', '--json',
250
+ stdin_data: '["fidget", "forgotten", "tokens"]',
253
251
  )
254
252
  expect(err).to eq('')
255
253
  expect(out).to eq('')
256
- expect(status.exitstatus).to eq(0)
257
254
 
258
255
  out, err = murano_command_run(
259
256
  'setting read', 'Webservice.cors', '-c', 'outformat=json',
@@ -15,7 +15,9 @@ RSpec.describe 'murano product setting', :cmd, :needs_password do
15
15
  include_context 'CI_CMD'
16
16
 
17
17
  before(:example) do
18
- @product_name = rname('settingtest')
18
+ @product_name = @snapshotter.resolve_var(
19
+ 'product.name', rname('settingtest')
20
+ )
19
21
  out, err = murano_command_run(
20
22
  'solution create', '--type', 'product', @product_name, '--save',
21
23
  )
@@ -74,13 +76,12 @@ RSpec.describe 'murano product setting', :cmd, :needs_password do
74
76
  end
75
77
 
76
78
  it 'a forced string value on STDIN', :club_10s do
77
- # FIXME: (lb): Replace capcmd with murano_command_run (need to handle stdin_data).
78
- out, err, status = Open3.capture3(capcmd(
79
- 'murano', 'setting', 'write', 'Device2.identity_format', 'prefix', '--string',
80
- ), stdin_data: 'fidget')
79
+ out, err = murano_command_run(
80
+ 'setting write', 'Device2.identity_format', 'prefix', '--string',
81
+ stdin_data: 'fidget',
82
+ )
81
83
  expect(err).to eq('')
82
84
  expect(out).to eq('')
83
- expect(status.exitstatus).to eq(0)
84
85
 
85
86
  out, err = murano_command_run(
86
87
  'setting read', 'Device2.identity_format', '-c', 'outformat=json',
@@ -152,13 +153,12 @@ RSpec.describe 'murano product setting', :cmd, :needs_password do
152
153
  end
153
154
 
154
155
  it 'on STDIN' do
155
- # FIXME: (lb): Replace capcmd with murano_command_run (need to handle stdin_data).
156
- out, err, status = Open3.capture3(capcmd(
157
- 'murano', 'setting', 'write', 'Device2.identity_format', 'options.length', '--num'
158
- ), stdin_data: '12')
156
+ out, err = murano_command_run(
157
+ 'setting write', 'Device2.identity_format', 'options.length', '--num',
158
+ stdin_data: '12',
159
+ )
159
160
  expect(err).to eq('')
160
161
  expect(out).to eq('')
161
- expect(status.exitstatus).to eq(0)
162
162
 
163
163
  out, err = murano_command_run(
164
164
  'setting read', 'Device2.identity_format', '-c', 'outformat=json',
@@ -238,9 +238,9 @@ RSpec.describe 'murano product setting', :cmd, :needs_password do
238
238
  expect(err).to eq('')
239
239
  end
240
240
  # {'origin'=>true,
241
- # 'methods'=>['HEAD', 'GET', 'POST', 'PUT', 'DELETE', 'OPTIONS', 'PATCH'],
242
- # 'headers'=>['Content-Type', 'Cookie', 'Authorization'],
243
- # 'credentials'=>true}
241
+ # 'methods'=>['HEAD', 'GET', 'POST', 'PUT', 'DELETE', 'OPTIONS', 'PATCH'],
242
+ # 'headers'=>['Content-Type', 'Cookie', 'Authorization'],
243
+ # 'credentials'=>true}
244
244
  end
245
245
  end
246
246
 
@@ -28,14 +28,18 @@ RSpec.describe 'murano status', :cmd, :needs_password do
28
28
  end
29
29
 
30
30
  before(:example) do
31
- @product_name = rname('statusTest')
31
+ @product_name = @snapshotter.resolve_var(
32
+ 'product.name', rname('statusTest')
33
+ )
32
34
  out, err = murano_command_run(
33
35
  'solution create', '--type', 'product', @product_name, '--save',
34
36
  )
35
37
  expect(err).to eq('')
36
38
  expect(out.chomp).to match(/^[a-zA-Z0-9]+$/)
37
39
 
38
- @applctn_name = rname('statusTest')
40
+ @applctn_name = @snapshotter.resolve_var(
41
+ 'application.name', rname('statusTest')
42
+ )
39
43
  out, err = murano_command_run(
40
44
  'solution create', '--type', 'application', @applctn_name, '--save',
41
45
  )
@@ -17,7 +17,9 @@ RSpec.describe 'murano single sync', :cmd, :needs_password do
17
17
  before(:example) do
18
18
  murano_solutions_expunge_yes
19
19
 
20
- @applctn_name = rname('syncdownTestApp')
20
+ @applctn_name = @snapshotter.resolve_var(
21
+ 'application.name', rname('syncdownTestApp')
22
+ )
21
23
  out, err = murano_command_run(
22
24
  'solution create', '--type', 'application', @applctn_name, '--save',
23
25
  )
@@ -15,14 +15,18 @@ RSpec.describe 'murano syncdown', :cmd, :needs_password do
15
15
  before(:example) do
16
16
  murano_solutions_expunge_yes
17
17
 
18
- @product_name = rname('syncdownTestPrd')
18
+ @product_name = @snapshotter.resolve_var(
19
+ 'product.name', rname('syncdownTestPrd')
20
+ )
19
21
  out, err = murano_command_run(
20
22
  'solution create', '--type', 'product', @product_name, '--save',
21
23
  )
22
24
  expect(err).to eq('')
23
25
  expect(out.chomp).to match(/^[a-zA-Z0-9]+$/)
24
26
 
25
- @applctn_name = rname('syncdownTestApp')
27
+ @applctn_name = @snapshotter.resolve_var(
28
+ 'application.name', rname('syncdownTestApp')
29
+ )
26
30
  out, err = murano_command_run(
27
31
  'solution create', '--type', 'application', @applctn_name, '--save',
28
32
  )
@@ -5,6 +5,9 @@
5
5
  # vim:tw=0:ts=2:sw=2:et:ai
6
6
  # Unauthorized copying of this file is strictly prohibited.
7
7
 
8
+ # FIXME/2018-08-08: (lb): The new webmock_snapshot.rb may
9
+ # have made this particular file very deletably trash-worthy.
10
+
8
11
  # NOTE: (lb): This test mimics the sync integration test,
9
12
  # cmd_syncdown_both_spec.rb, implemented as a unit test
10
13
  # (by stubbing all the HTTP calls).