MuranoCLI 3.2.0.beta.9 → 3.2.1.pre.beta.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -0
  3. data/Rakefile +5 -0
  4. data/dockers/README.rst +7 -0
  5. data/dockers/RELEASE.rst +6 -3
  6. data/dockers/docker-test.sh +45 -17
  7. data/docs/completions/murano_completion-bash +211 -86
  8. data/lib/MrMurano/Account.rb +72 -4
  9. data/lib/MrMurano/Business.rb +163 -2
  10. data/lib/MrMurano/Commander-Entry.rb +1 -2
  11. data/lib/MrMurano/Config.rb +19 -18
  12. data/lib/MrMurano/Content.rb +26 -19
  13. data/lib/MrMurano/Gateway.rb +51 -10
  14. data/lib/MrMurano/ReCommander.rb +1 -1
  15. data/lib/MrMurano/Solution-Services.rb +80 -35
  16. data/lib/MrMurano/Solution-Users.rb +1 -0
  17. data/lib/MrMurano/SyncRoot.rb +10 -3
  18. data/lib/MrMurano/SyncUpDown-Core.rb +47 -36
  19. data/lib/MrMurano/SyncUpDown-Item.rb +46 -14
  20. data/lib/MrMurano/SyncUpDown.rb +22 -20
  21. data/lib/MrMurano/Webservice-Endpoint.rb +20 -18
  22. data/lib/MrMurano/Webservice-File.rb +63 -20
  23. data/lib/MrMurano/commands/business.rb +14 -1
  24. data/lib/MrMurano/commands/child.rb +148 -0
  25. data/lib/MrMurano/commands/devices.rb +298 -149
  26. data/lib/MrMurano/commands/element.rb +2 -1
  27. data/lib/MrMurano/commands/globals.rb +3 -0
  28. data/lib/MrMurano/commands/network.rb +152 -33
  29. data/lib/MrMurano/commands/sync.rb +2 -2
  30. data/lib/MrMurano/commands.rb +1 -0
  31. data/lib/MrMurano/verbosing.rb +13 -2
  32. data/lib/MrMurano/version.rb +1 -1
  33. data/spec/Account_spec.rb +43 -11
  34. data/spec/Content_spec.rb +5 -3
  35. data/spec/GatewayBase_spec.rb +1 -1
  36. data/spec/GatewayDevice_spec.rb +47 -8
  37. data/spec/GatewayResource_spec.rb +1 -1
  38. data/spec/GatewaySettings_spec.rb +1 -1
  39. data/spec/HttpAuthed_spec.rb +17 -3
  40. data/spec/ProjectFile_spec.rb +59 -23
  41. data/spec/Setting_spec.rb +2 -1
  42. data/spec/Solution-ServiceConfig_spec.rb +1 -1
  43. data/spec/Solution-ServiceEventHandler_spec.rb +27 -20
  44. data/spec/Solution-ServiceModules_spec.rb +7 -5
  45. data/spec/Solution-UsersRoles_spec.rb +7 -1
  46. data/spec/Solution_spec.rb +9 -1
  47. data/spec/SyncRoot_spec.rb +5 -5
  48. data/spec/SyncUpDown_spec.rb +262 -211
  49. data/spec/Verbosing_spec.rb +49 -8
  50. data/spec/Webservice-Cors_spec.rb +10 -1
  51. data/spec/Webservice-Endpoint_spec.rb +84 -65
  52. data/spec/Webservice-File_spec.rb +16 -11
  53. data/spec/Webservice-Setting_spec.rb +7 -1
  54. data/spec/_workspace.rb +9 -0
  55. data/spec/cmd_business_spec.rb +5 -10
  56. data/spec/cmd_common.rb +67 -32
  57. data/spec/cmd_config_spec.rb +9 -14
  58. data/spec/cmd_content_spec.rb +15 -26
  59. data/spec/cmd_cors_spec.rb +9 -12
  60. data/spec/cmd_device_spec.rb +31 -45
  61. data/spec/cmd_domain_spec.rb +12 -10
  62. data/spec/cmd_element_spec.rb +18 -17
  63. data/spec/cmd_exchange_spec.rb +1 -4
  64. data/spec/cmd_init_spec.rb +56 -72
  65. data/spec/cmd_keystore_spec.rb +17 -26
  66. data/spec/cmd_link_spec.rb +13 -17
  67. data/spec/cmd_password_spec.rb +9 -10
  68. data/spec/cmd_setting_application_spec.rb +95 -68
  69. data/spec/cmd_setting_product_spec.rb +59 -37
  70. data/spec/cmd_status_spec.rb +46 -84
  71. data/spec/cmd_syncdown_application_spec.rb +28 -50
  72. data/spec/cmd_syncdown_both_spec.rb +44 -93
  73. data/spec/cmd_syncdown_unit_spec.rb +858 -0
  74. data/spec/cmd_syncup_spec.rb +21 -56
  75. data/spec/cmd_token_spec.rb +0 -3
  76. data/spec/cmd_usage_spec.rb +15 -10
  77. data/spec/dry_run_formatter.rb +1 -0
  78. data/spec/fixtures/dumped_config +4 -4
  79. data/spec/spec_helper.rb +3 -0
  80. metadata +4 -2
@@ -14,24 +14,24 @@ RSpec.describe 'murano cors', :cmd, :needs_password do
14
14
  include_context 'CI_CMD'
15
15
 
16
16
  before(:example) do
17
- @product_name = rname('corstest')
18
- out, err, status = Open3.capture3(capcmd('murano', 'application', 'create', @product_name, '--save'))
17
+ @application_name = rname('corstest')
18
+ out, err = murano_command_run(
19
+ 'solution create', '--type', 'application', @application_name, '--save',
20
+ )
19
21
  expect(err).to eq('')
20
22
  expect(out.chomp).to match(/^[a-zA-Z0-9]+$/)
21
- expect(status.exitstatus).to eq(0)
22
23
  end
24
+
23
25
  after(:example) do
24
- out, err, status = Open3.capture3(capcmd('murano', 'solution', 'delete', @product_name, '-y'))
26
+ out, err = murano_command_run('solution delete', @application_name, '-y')
25
27
  expect(out).to eq('')
26
28
  expect(err).to eq('')
27
- expect(status.exitstatus).to eq(0)
28
29
  end
29
30
 
30
31
  it 'show CORS' do
31
- out, err, status = Open3.capture3(capcmd('murano', 'cors', '-c', 'outformat=json'))
32
+ out, err = murano_command_run('cors', '-c', 'outformat=json')
32
33
  expect { JSON.parse(out) }.to_not raise_error
33
34
  expect(err).to eq('')
34
- expect(status.exitstatus).to eq(0)
35
35
  end
36
36
 
37
37
  it 'sets CORS' do
@@ -39,17 +39,14 @@ RSpec.describe 'murano cors', :cmd, :needs_password do
39
39
  io << { origin: ['http://localhost:*'] }.to_json
40
40
  end
41
41
 
42
- out, err, status = Open3.capture3(capcmd('murano', 'cors', 'set', 'cors.yaml'))
42
+ out, err = murano_command_run('cors set', 'cors.yaml')
43
43
  expect(out).to eq('')
44
44
  expect(err).to eq('')
45
- expect(status.exitstatus).to eq(0)
46
45
 
47
- out, err, status = Open3.capture3(capcmd('murano', 'cors', '-c', 'outformat=json'))
46
+ out, err = murano_command_run('cors', '-c', 'outformat=json')
48
47
  expect { out = JSON.parse(out) }.to_not raise_error
49
48
  expect(out).to include('origin' => contain_exactly('http://localhost:*'))
50
49
  expect(err).to eq('')
51
- expect(status.exitstatus).to eq(0)
52
50
  end
53
51
  end
54
52
 
55
- # vim: set ai et sw=2 ts=2 :
@@ -14,25 +14,27 @@ RSpec.describe 'murano device', :cmd, :needs_password do
14
14
 
15
15
  before(:example) do
16
16
  @product_name = rname('deviceTest')
17
- out, err, status = Open3.capture3(capcmd('murano', 'product', 'create', @product_name, '--save'))
17
+ out, err = murano_command_run(
18
+ 'solution create', '--type', 'product', @product_name, '--save',
19
+ )
18
20
  expect(err).to eq('')
19
21
  expect(out.chomp).to match(/^[a-zA-Z0-9]+$/)
20
- expect(status.exitstatus).to eq(0)
21
22
  end
23
+
22
24
  after(:example) do
23
- out, err, status = Open3.capture3(capcmd('murano', 'solution', 'delete', '-y', @product_name))
25
+ out, err = murano_command_run(
26
+ 'solution delete', '-y', @product_name,
27
+ )
24
28
  expect(out).to eq('')
25
29
  expect(err).to eq('')
26
- expect(status.exitstatus).to eq(0)
27
30
  end
28
31
 
29
32
  it 'enables and lists' do
30
- out, err, status = Open3.capture3(capcmd('murano', 'product', 'device', 'enable', '12345'))
33
+ out, err = murano_command_run('product device enable', '12345')
31
34
  expect(out).to eq('')
32
35
  expect(err).to eq('')
33
- expect(status.exitstatus).to eq(0)
34
36
 
35
- out, err, status = Open3.capture3(capcmd('murano', 'product', 'device', 'list'))
37
+ out, err = murano_command_run('product device list')
36
38
  expect(err).to eq('')
37
39
  olines = out.lines
38
40
  expect(olines[0]).to match(/^(\+-+){3}\+$/)
@@ -40,7 +42,6 @@ RSpec.describe 'murano device', :cmd, :needs_password do
40
42
  expect(olines[2]).to match(/^(\+-+){3}\+$/)
41
43
  expect(olines[3]).to match(/^\| 12345\s+\| whitelisted\s+\| false\s+\|$/)
42
44
  expect(olines[4]).to match(/^(\+-+){3}\+$/)
43
- expect(status.exitstatus).to eq(0)
44
45
  end
45
46
 
46
47
  it 'enables a batch' do
@@ -51,13 +52,11 @@ RSpec.describe 'murano device', :cmd, :needs_password do
51
52
  io << "1236\n"
52
53
  end
53
54
 
54
- out, err, status = Open3.capture3(capcmd('murano', 'product', 'device', 'enable', '--file', 'ids.csv'))
55
+ out, err = murano_command_run('product device enable', '--file', 'ids.csv')
55
56
  expect(out).to eq('')
56
57
  expect(err).to eq('')
57
- expect(status.exitstatus).to eq(0)
58
58
 
59
- out, err, status = Open3.capture3(capcmd('murano', 'product', 'device', 'list'))
60
- expect(err).to eq('')
59
+ out, err = murano_command_run('product device list')
61
60
  olines = out.lines
62
61
  expect(olines[0]).to match(/^(\+-+){3}\+$/)
63
62
  expect(olines[1]).to match(/^\| Identifier\s+\| Status\s+\| Online\s+\|$/)
@@ -66,22 +65,17 @@ RSpec.describe 'murano device', :cmd, :needs_password do
66
65
  expect(olines[4]).to match(/^\| 1235\s+\| whitelisted\s+\| false\s+\|$/)
67
66
  expect(olines[5]).to match(/^\| 1236\s+\| whitelisted\s+\| false\s+\|$/)
68
67
  expect(olines[6]).to match(/^(\+-+){3}\+$/)
69
- expect(status.exitstatus).to eq(0)
68
+ expect(err).to eq('')
70
69
  end
71
70
 
72
71
  it 'activates' do
73
- out, err, status = Open3.capture3(capcmd('murano', 'product', 'device', 'enable', '12345'))
72
+ out, err = murano_command_run('product device enable', '12345')
74
73
  expect(out).to eq('')
75
74
  expect(err).to eq('')
76
- expect(status.exitstatus).to eq(0)
77
75
 
78
- out, err, status = Open3.capture3(capcmd('murano', 'product', 'device', 'activate', '12345'))
79
- # 2017-06-01: This used to return hex, e.g., /^\h{40}$/, but now returns
80
- # a-zA-Z0-9 (but not \w, which also includes underscore).
81
- #expect(out.chomp).to match(/^\h{40}$/)
82
- expect(out.chomp).to match(/^[a-zA-Z0-9]{40}$/)
76
+ out, err = murano_command_run('product device activate', '12345')
77
+ expect(out.chomp).to match(/^[{}a-zA-Z0-9]{40}$/)
83
78
  expect(err).to eq('')
84
- expect(status.exitstatus).to eq(0)
85
79
  end
86
80
 
87
81
  it 'writes and reads', :club_10s do
@@ -91,40 +85,33 @@ RSpec.describe 'murano device', :cmd, :needs_password do
91
85
  'specs/resources.yaml',
92
86
  )
93
87
 
94
- out, err, status = Open3.capture3(capcmd('murano', 'syncup', '--resources'))
95
- expect(out).to eq("Adding item state\nAdding item temperature\nAdding item uptime\nAdding item humidity\nUpdating remote product resources\n")
88
+ out, err = murano_command_run('syncup', '--resources')
89
+ expect(out).to eq(
90
+ "Adding item state\n" +
91
+ "Adding item temperature\n" +
92
+ "Adding item uptime\n" +
93
+ "Adding item humidity\n" +
94
+ "Updating remote product resources\n"
95
+ )
96
96
  expect(err).to eq('')
97
- expect(status.exitstatus).to eq(0)
98
97
 
99
- out, err, status = Open3.capture3(capcmd('murano', 'product', 'device', 'enable', '12345'))
98
+ out, err = murano_command_run('product device enable', '12345')
100
99
  expect(out).to eq('')
101
100
  expect(err).to eq('')
102
- expect(status.exitstatus).to eq(0)
103
101
 
104
- out, err, status = Open3.capture3(capcmd('murano', 'product', 'device', 'activate', '12345'))
102
+ out, err = murano_command_run('product device activate', '12345')
105
103
  # 2017-06-01: This used to return hex, e.g., /^\h{40}$/, but now returns
106
104
  # a-zA-Z0-9 (but not \w, which also includes underscore).
107
- expect(out.chomp).to match(/^[a-zA-Z0-9]{40}$/)
105
+ # 2018-07-18: (lb): Now I'm also seeing curly braces. It might help-
106
+ # ful to see the spec. on exactly what the acceptable format is...
107
+ expect(out.chomp).to match(/^[{}a-zA-Z0-9]{40}$/)
108
108
  expect(err).to eq('')
109
- expect(status.exitstatus).to eq(0)
110
-
111
- # out, err, status = Open3.capture3(capcmd('murano', 'product', 'device', 'twee', '12345'))
112
- # expect(err).to eq('')
113
- # olines = out.lines
114
- # expect(olines[0]).to match(/^(\+-+){4}\+$/)
115
- # expect(olines[1]).to match(/^\|\s+12345\s+activated\s+\|$/)
116
- # expect(olines[2]).to match(/^(\+-+){4}\+$/)
117
- # expect(olines[3]).to match(/^\| Resource\s+\| Format\s+\| Modified\s+\| Value\s+\|$/)
118
- # expect(olines[4]).to match(/^(\+-+){4}\+$/)
119
- # expect(olines[-1]).to match(/^(\+-+){4}\+$/)
120
- # expect(status.exitstatus).to eq(0)
121
-
122
- out, err, status = Open3.capture3(capcmd('murano', 'product', 'device', 'write', '12345', 'state=42'))
109
+
110
+ out, err = murano_command_run('product device write', '12345', 'state=42')
123
111
  expect(out).to eq('')
124
112
  expect(err).to eq('')
125
- expect(status.exitstatus).to eq(0)
126
113
 
127
- out, err, status = Open3.capture3(capcmd('murano', 'product', 'device', 'read', '12345', 'state'))
114
+ out, err = murano_command_run('product device read', '12345', 'state')
128
115
  #expect(out.strip).to eq('42')
129
116
  expect(err).to eq('')
130
117
  expect(out.lines).to match_array(
@@ -136,7 +123,6 @@ RSpec.describe 'murano device', :cmd, :needs_password do
136
123
  /^(\+-+){4}\+$/,
137
124
  ]
138
125
  )
139
- expect(status.exitstatus).to eq(0)
140
126
  end
141
127
  end
142
128
 
@@ -14,29 +14,32 @@ RSpec.describe 'murano domain', :cmd, :needs_password do
14
14
 
15
15
  before(:example) do
16
16
  @product_name = rname('domainTest')
17
- out, err, status = Open3.capture3(capcmd('murano', 'product', 'create', @product_name, '--save'))
17
+ out, err = murano_command_run(
18
+ 'solution create', '--type', 'product', @product_name, '--save',
19
+ )
18
20
  expect(err).to eq('')
19
21
  expect(out.chomp).to match(/^[a-zA-Z0-9]+$/)
20
- expect(status.exitstatus).to eq(0)
21
- out, err, status = Open3.capture3(capcmd('murano', 'application', 'create', @product_name, '--save'))
22
+
23
+ @application_name = rname('domainTest')
24
+ out, err = murano_command_run(
25
+ 'solution create', '--type', 'application', @application_name, '--save',
26
+ )
22
27
  expect(err).to eq('')
23
28
  expect(out.chomp).to match(/^[a-zA-Z0-9]+$/)
24
- expect(status.exitstatus).to eq(0)
25
29
  end
26
30
 
27
31
  after(:example) do
28
- out, err, status = Open3.capture3(capcmd('murano', 'product', 'delete', @product_name, '-y'))
32
+ out, err = murano_command_run('product delete', @product_name, '-y')
29
33
  expect(out).to eq('')
30
34
  expect(err).to eq('')
31
- expect(status.exitstatus).to eq(0)
32
- out, err, status = Open3.capture3(capcmd('murano', 'application', 'delete', @product_name, '--yes'))
35
+
36
+ out, err = murano_command_run('application delete', @application_name, '--yes')
33
37
  expect(out).to eq('')
34
38
  expect(err).to eq('')
35
- expect(status.exitstatus).to eq(0)
36
39
  end
37
40
 
38
41
  it 'show domain', :club_20s, :club_10s do
39
- out, err, status = Open3.capture3(capcmd('murano', 'domain'))
42
+ out, err = murano_command_run('domain')
40
43
  # 2017-05-31: Previously, the project could be named whatever and
41
44
  # the URI would start with the same.
42
45
  # expect(out.chomp).to start_with("#{@product_name.downcase}.apps.exosite").and end_with('.io')
@@ -50,7 +53,6 @@ RSpec.describe 'murano domain', :cmd, :needs_password do
50
53
  )
51
54
  end
52
55
  expect(err).to eq('')
53
- expect(status.exitstatus).to eq(0)
54
56
  end
55
57
  end
56
58
 
@@ -68,21 +68,21 @@ RSpec.describe 'murano element', :cmd, :needs_password do
68
68
 
69
69
  it 'as default-table' do
70
70
  # FIXME/2018-04-30: Make test-specific elements for this test!
71
- stdout, stderr = murano_command_run('element show', 'MUR-6407')
71
+ stdout, stderr = murano_command_run('element show', 'Security as a Culture')
72
72
  expect_exchange_element_table(stdout, stderr, num_cols: 2)
73
73
  expect(stderr).to eq('')
74
74
  end
75
75
 
76
76
  it 'as table wrap' do
77
77
  # FIXME/2018-04-30: Make test-specific elements for this test!
78
- stdout, stderr = murano_command_run('element show', 'MUR-6407', '--wrap')
78
+ stdout, stderr = murano_command_run('element show', 'Security as a Culture', '--wrap')
79
79
  expect_exchange_element_table(stdout, stderr, num_cols: 2)
80
80
  expect(stderr).to eq('')
81
81
  end
82
82
 
83
83
  it 'as table truncate' do
84
84
  # FIXME/2018-04-30: Make test-specific elements for this test!
85
- stdout, stderr = murano_command_run('element show', 'MUR-6407', '--truncate')
85
+ stdout, stderr = murano_command_run('element show', 'Security as a Culture', '--truncate')
86
86
  expect_exchange_element_table(stdout, stderr, num_cols: 2)
87
87
  expect(stderr).to eq('')
88
88
  end
@@ -90,7 +90,7 @@ RSpec.describe 'murano element', :cmd, :needs_password do
90
90
  # (lb): NOTE: This does not add any additional coverage to element.rb:
91
91
  it 'as json' do
92
92
  # FIXME/2018-04-30: Make test-specific elements for this test!
93
- stdout, stderr = murano_command_run('element show', '--json', 'MUR-6407')
93
+ stdout, stderr = murano_command_run('element show', '--json', 'Security as a Culture')
94
94
  expect { JSON.parse(stdout) }.to_not raise_error
95
95
  expect(stderr).to eq('')
96
96
  end
@@ -98,7 +98,7 @@ RSpec.describe 'murano element', :cmd, :needs_password do
98
98
  # (lb): NOTE: This does not add any additional coverage to element.rb:
99
99
  it 'as yaml' do
100
100
  # FIXME/2018-04-30: Make test-specific elements for this test!
101
- stdout, stderr = murano_command_run('element show', 'MUR-6407', '--yaml')
101
+ stdout, stderr = murano_command_run('element show', 'Security as a Culture', '--yaml')
102
102
  expect { YAML.parse(stdout) }.to_not raise_error
103
103
  expect(stderr).to eq('')
104
104
  end
@@ -106,13 +106,14 @@ RSpec.describe 'murano element', :cmd, :needs_password do
106
106
  # (lb): This adds 1 line of coverage.
107
107
  it 'as csv' do
108
108
  # FIXME/2018-04-30: Make test-specific elements for this test!
109
- stdout, stderr = murano_command_run('element show', 'MUR-6407', '--csv')
109
+ stdout, stderr = murano_command_run('element show', 'Security as a Culture', '--csv')
110
110
  expect(stdout).to_not eq('')
111
111
  expect(stderr).to eq('')
112
112
  end
113
113
  end
114
114
 
115
- context 'edit' do
115
+ # FIXME/2018-07-12: (lb): Make test acct. with element. 'til then: disabled.
116
+ context 'edit', :needs_exchange_element do
116
117
  before(:example) do
117
118
  @json_input_file = 'element-show.json'
118
119
  @spec_swagger_20k = 'swagger-mur-6407__20k.yaml'
@@ -160,16 +161,6 @@ RSpec.describe 'murano element', :cmd, :needs_password do
160
161
  end
161
162
  end
162
163
 
163
- # DEL:
164
- def element_editor_expect_edit_json_from_string
165
- expect(TTY::Editor).to receive(:open) do |path|
166
- pname = path.is_a?(Pathname) && path || Pathname.new(path)
167
- pname.write(
168
- %({"tiers":[],"bizid":"55cop31gs89","access":"private","attachment":{},"contact":"#{rname}","description":"For testing Murano CLI element-edit.\\n\\nTEST2222\\n\\nTEST MORE","image":{"detail":{"color":"#224123","filename":"","url":""},"thumbnail":{"color":"#224655","filename":"xxx","url":""}},"markdown":"AxxxxAA2333BBBCCC\\n","name":"MUR-6407 Test Element","source":{"from":"service","name":"mur6407testelement","url":"https://testtesttest.apps.exosite-dev.io/swagger-mur-6407.yaml"},"specs":"","type":"service","tags":[],"active":true,"approval":"approved","elementId":"5ae3600e313d01708c2a6e0f"})
169
- )
170
- end
171
- end
172
-
173
164
  it '--help' do
174
165
  stdout, stderr = murano_command_wont_parse('element edit', '--help')
175
166
  expect(stdout).to a_string_starting_with('Usage:')
@@ -396,5 +387,15 @@ RSpec.describe 'murano element', :cmd, :needs_password do
396
387
  expect(stderr).to eq %(Request Failed: 400: [400] "tiers" is not allowed. "approval" is not allowed\n)
397
388
  end
398
389
  end
390
+
391
+ context 'edit unknown' do
392
+ it 'as unknown element' do
393
+ stdout, stderr = murano_command_exits(
394
+ 'element edit', '-e', '', 'BLAH-BLAH-BLAH-NO-NAME-MATCH'
395
+ )
396
+ expect(stdout).to eq('')
397
+ expect(stderr).to eq %(No matching element was found.\n)
398
+ end
399
+ end
399
400
  end
400
401
 
@@ -21,9 +21,6 @@ RSpec.describe 'murano exchange', :cmd, :needs_password do
21
21
  end
22
22
 
23
23
  context 'with project' do
24
- #before(:example) { project_up }
25
- #after(:example) { project_down }
26
-
27
24
  def expect_exchange_element_table(stdout, stderr, num_cols: nil)
28
25
  expect(stderr).to eq('')
29
26
  lines = stdout.lines
@@ -96,7 +93,7 @@ RSpec.describe 'murano exchange', :cmd, :needs_password do
96
93
  stdout, stderr = murano_command_exits('exchange purchase', 'IoT')
97
94
  expect(stdout).to eq('')
98
95
  expect(stderr).to a_string_starting_with(
99
- 'Please be more specific: More than one matching element was found: '
96
+ "Please be more specific: More than one matching element was found:\n "
100
97
  )
101
98
  end
102
99
 
@@ -13,7 +13,7 @@ RSpec.describe 'murano init', :cmd do
13
13
  include_context 'CI_CMD'
14
14
 
15
15
  def expected_response_when_ids_found_in_config(
16
- t,
16
+ test,
17
17
  expect_rebasing: false,
18
18
  has_one_each_soln: false,
19
19
  has_no_solutions: false,
@@ -29,18 +29,18 @@ RSpec.describe 'murano init', :cmd do
29
29
  ]
30
30
  if !expect_rebasing
31
31
  expecting += [
32
- t.a_string_starting_with('Creating project at '), # 1
32
+ test.a_string_starting_with('Creating project at '), # 1
33
33
  ]
34
34
  else
35
35
  expecting += [
36
- t.a_string_starting_with('Rebasing project at '), # 1
36
+ test.a_string_starting_with('Rebasing project at '), # 1
37
37
  ]
38
38
  end
39
39
  expecting += [
40
40
  "\n", # 2
41
- t.a_string_starting_with('Found User '), # 3
41
+ test.a_string_starting_with('Found User '), # 3
42
42
  "\n", # 4
43
- t.a_string_starting_with('Found Business '), # 5
43
+ test.a_string_starting_with('Found Business '), # 5
44
44
  "\n", # 6
45
45
  ]
46
46
  if has_one_each_soln
@@ -65,16 +65,16 @@ RSpec.describe 'murano init', :cmd do
65
65
  ]
66
66
  else
67
67
  expecting += [
68
- t.a_string_starting_with('Found Application '), # 7
68
+ test.a_string_starting_with('Found Application '), # 7
69
69
  "\n", # 8
70
- t.a_string_starting_with('Found Product '), # 9
70
+ test.a_string_starting_with('Found Product '), # 9
71
71
  "\n", # 10
72
72
  ]
73
73
  end
74
74
  expecting += [
75
- t.a_string_matching(/Linked '\w+' to '\w+'\n/),
75
+ test.a_string_matching(/Linked '\w+' to '\w+'\n/),
76
76
  "\n",
77
- t.a_string_matching(/Created default event handler\n/),
77
+ test.a_string_matching(/Created default event handler\n/),
78
78
  "\n",
79
79
  ]
80
80
  if expect_proj_file_write
@@ -108,34 +108,26 @@ RSpec.describe 'murano init', :cmd do
108
108
  ]
109
109
  end
110
110
 
111
- # 2017-12-15: Currently:
112
- # services{product.id}_event.lua
113
- # services/user_account.lua
114
- # specs/resources.yaml
115
- # 2018-04-11: Currently:
111
+ # 2018-07-23: Currently:
116
112
  # "Updating local product resources\n",
117
- # "Adding item config_service\n",
118
- # "Adding item config_status\n",
119
113
  # "Adding item user_account\n",
120
114
  # "Adding item g3vm2aa9xjfy00000_event\n",
121
- # "Adding item config_service\n",
122
- # "Adding item config_status\n",
123
- # "Synced 7 items\n",
115
+ # "Synced 3 items\n",
124
116
  expecting += [
125
117
  "Updating local product resources\n",
126
118
  ]
127
- 6.times { expecting += [t.a_string_starting_with('Adding item ')] }
119
+ 2.times { expecting += [test.a_string_starting_with('Adding item ')] }
128
120
  expecting += [
129
- "Synced 7 items\n",
121
+ "Synced 3 items\n",
130
122
  "\n",
131
123
  ]
132
124
 
133
125
  expecting += [
134
126
  "Success!\n",
135
127
  "\n",
136
- t.a_string_matching(/\s+Business ID: \w+\n/),
137
- t.a_string_matching(/(\s+Application ID: \w+\n)?/),
138
- t.a_string_matching(/(\s+Product ID: \w+\n)?/),
128
+ test.a_string_matching(/\s+Business ID: \w+\n/),
129
+ test.a_string_matching(/(\s+Application ID: \w+\n)?/),
130
+ test.a_string_matching(/(\s+Product ID: \w+\n)?/),
139
131
  "\n",
140
132
  ]
141
133
  expecting
@@ -144,10 +136,9 @@ RSpec.describe 'murano init', :cmd do
144
136
  it %(Won't init in HOME (gracefully)) do
145
137
  # this is in the project dir. Want to be in HOME
146
138
  Dir.chdir(ENV['HOME']) do
147
- out, err, status = Open3.capture3(capcmd('murano', 'init'))
139
+ out, err = murano_command_exits('init')
148
140
  expect(out).to eq('')
149
- expect(err).to eq("\e[31mCannot init a project in your HOME directory.\e[0m\n")
150
- expect(status.exitstatus).to eq(2)
141
+ expect(err).to eq("Cannot init a project in your HOME directory.\n")
151
142
  end
152
143
  end
153
144
 
@@ -160,45 +151,41 @@ RSpec.describe 'murano init', :cmd do
160
151
  murano_solutions_expunge_yes
161
152
 
162
153
  @applctn_name = rname('initEmptyApp')
163
- out, err, status = Open3.capture3(
164
- capcmd('murano', 'application', 'create', @applctn_name, '--save')
154
+ out, err = murano_command_run(
155
+ 'solution create', '--type', 'application', @applctn_name, '--save',
165
156
  )
166
157
  expect(err).to eq('')
167
158
  expect(out.chomp).to match(/^[a-zA-Z0-9]+$/)
168
- expect(status.exitstatus).to eq(0)
169
159
 
170
160
  @product_name = rname('initEmptyPrd')
171
- out, err, status = Open3.capture3(
172
- capcmd('murano', 'product', 'create', @product_name, '--save')
161
+ out, err = murano_command_run(
162
+ 'solution create', '--type', 'product', @product_name, '--save',
173
163
  )
174
164
  expect(err).to eq('')
175
165
  expect(out.chomp).to match(/^[a-zA-Z0-9]+$/)
176
- expect(status.exitstatus).to eq(0)
177
166
 
178
167
  # delete all of this so it is a empty directory.
179
168
  FileUtils.remove_entry('.murano')
180
169
  end
181
170
 
182
171
  after(:example) do
183
- out, err, status = Open3.capture3(
184
- capcmd('murano', 'solution', 'delete', @product_name, '-y')
172
+ out, err = murano_command_run(
173
+ 'solution delete', @product_name, '-y',
185
174
  )
186
175
  expect(out).to eq('')
187
176
  expect(err).to eq('')
188
- expect(status.exitstatus).to eq(0)
189
177
 
190
- out, err, status = Open3.capture3(
191
- capcmd('murano', 'solution', 'delete', @applctn_name, '-y')
178
+ out, err = murano_command_run(
179
+ 'solution delete', @applctn_name, '-y',
192
180
  )
193
181
  expect(out).to eq('')
194
182
  expect(err).to eq('')
195
- expect(status.exitstatus).to eq(0)
196
183
  end
197
184
 
198
185
  it 'existing project', :club_20s, :club_10s do
199
186
  # The test account will have one business, one product, and one application.
200
187
  # So it won't ask any questions.
201
- out, err, status = Open3.capture3(capcmd('murano', 'init'))
188
+ out, err = murano_command_run('init')
202
189
  expecting = expected_response_when_ids_found_in_config(
203
190
  self,
204
191
  has_one_each_soln: true,
@@ -206,13 +193,14 @@ RSpec.describe 'murano init', :cmd do
206
193
  out_lines = out.lines.map { |line| strip_fancy(line) }
207
194
  expect(out_lines).to match_array(expecting)
208
195
  expect(err).to eq('')
209
- expect(status.exitstatus).to eq(0)
210
196
 
211
197
  expect(File.directory?('.murano')).to be true
212
198
  expect(File.exist?('.murano/config')).to be true
213
- expect(File.directory?('routes')).to be true
199
+ expect(File.directory?('routes')).to be false
200
+ expect(File.directory?('endpoints')).to be true
214
201
  expect(File.directory?('services')).to be true
215
- expect(File.directory?('files')).to be true
202
+ expect(File.directory?('files')).to be false
203
+ expect(File.directory?('assets')).to be true
216
204
  expect(File.directory?('modules')).to be true
217
205
  expect(File.directory?('specs')).to be true
218
206
  end
@@ -225,19 +213,17 @@ RSpec.describe 'murano init', :cmd do
225
213
  @product_name = rname('initCreatingPrd')
226
214
  end
227
215
  after(:example) do
228
- out, err, status = Open3.capture3(
229
- capcmd('murano', 'solution', 'delete', @product_name, '-y')
216
+ out, err = murano_command_run(
217
+ 'solution delete', @product_name, '-y',
230
218
  )
231
219
  expect(out).to eq('')
232
220
  expect(err).to eq('')
233
- expect(status.exitstatus).to eq(0)
234
221
 
235
- out, err, status = Open3.capture3(
236
- capcmd('murano', 'solution', 'delete', @applctn_name, '-y')
222
+ out, err = murano_command_run(
223
+ 'solution delete', @applctn_name, '-y',
237
224
  )
238
225
  expect(out).to eq('')
239
226
  expect(err).to eq('')
240
- expect(status.exitstatus).to eq(0)
241
227
  end
242
228
 
243
229
  it 'existing project', :club_20s, :club_10s do
@@ -250,6 +236,7 @@ RSpec.describe 'murano init', :cmd do
250
236
  #{@product_name}
251
237
  DATA
252
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?
253
240
  out, err, status = Open3.capture3(capcmd('murano', 'init'), stdin_data: data)
254
241
  expecting = expected_response_when_ids_found_in_config(
255
242
  self,
@@ -296,9 +283,11 @@ RSpec.describe 'murano init', :cmd do
296
283
 
297
284
  expect(File.directory?('.murano')).to be true
298
285
  expect(File.exist?('.murano/config')).to be true
299
- expect(File.directory?('routes')).to be true
286
+ expect(File.directory?('routes')).to be false
287
+ expect(File.directory?('endpoints')).to be true
300
288
  expect(File.directory?('services')).to be true
301
- expect(File.directory?('files')).to be true
289
+ expect(File.directory?('files')).to be false
290
+ expect(File.directory?('assets')).to be true
302
291
  expect(File.directory?('modules')).to be true
303
292
  expect(File.directory?('specs')).to be true
304
293
  end
@@ -313,40 +302,36 @@ RSpec.describe 'murano init', :cmd do
313
302
  FileUtils.move('assets', 'files')
314
303
 
315
304
  @applctn_name = rname('initEmptyApp')
316
- out, err, status = Open3.capture3(
317
- capcmd('murano', 'application', 'create', @applctn_name, '--save')
305
+ out, err = murano_command_run(
306
+ 'solution create', '--type', 'application', @applctn_name, '--save',
318
307
  )
319
308
  expect(err).to eq('')
320
309
  expect(out.chomp).to match(/^[a-zA-Z0-9]+$/)
321
- expect(status.exitstatus).to eq(0)
322
310
 
323
311
  @product_name = rname('initEmptyPrd')
324
- out, err, status = Open3.capture3(
325
- capcmd('murano', 'product', 'create', @product_name, '--save')
312
+ out, err = murano_command_run(
313
+ 'solution create', '--type', 'product', @product_name, '--save',
326
314
  )
327
315
  expect(err).to eq('')
328
316
  expect(out.chomp).to match(/^[a-zA-Z0-9]+$/)
329
- expect(status.exitstatus).to eq(0)
330
317
  end
331
318
 
332
319
  after(:example) do
333
320
  Dir.chdir(ENV['HOME']) do
334
321
  if defined?(@product_name)
335
- out, err, status = Open3.capture3(
336
- capcmd('murano', 'solution', 'delete', @product_name, '-y')
322
+ out, err = murano_command_run(
323
+ 'solution delete', @product_name, '-y',
337
324
  )
338
325
  expect(out).to eq('')
339
326
  expect(err).to eq('')
340
- expect(status.exitstatus).to eq(0)
341
327
  end
342
328
 
343
329
  if defined?(@applctn_name)
344
- out, err, status = Open3.capture3(
345
- capcmd('murano', 'solution', 'delete', @applctn_name, '-y')
330
+ out, err = murano_command_run(
331
+ 'solution delete', @applctn_name, '-y',
346
332
  )
347
333
  expect(out).to eq('')
348
334
  expect(err).to eq('')
349
- expect(status.exitstatus).to eq(0)
350
335
  end
351
336
  end
352
337
  end
@@ -354,7 +339,7 @@ RSpec.describe 'murano init', :cmd do
354
339
  it 'without ProjectFile', :club_20s, :club_10s do
355
340
  # The test account will have one business, one product, and one application.
356
341
  # So it won't ask any questions.
357
- out, err, status = Open3.capture3(capcmd('murano', 'init'))
342
+ out, err = murano_command_run('init')
358
343
  the_expected = expected_response_when_ids_found_in_config(
359
344
  self,
360
345
  expect_rebasing: true,
@@ -363,7 +348,6 @@ RSpec.describe 'murano init', :cmd do
363
348
  out_lines = out.lines.map { |line| strip_fancy(line) }
364
349
  expect(out_lines).to match_array(the_expected)
365
350
  expect(err).to eq('')
366
- expect(status.exitstatus).to eq(0)
367
351
 
368
352
  expect(File.directory?('.murano')).to be true
369
353
  expect(File.exist?('.murano/config')).to be true
@@ -375,10 +359,13 @@ RSpec.describe 'murano init', :cmd do
375
359
  end
376
360
 
377
361
  it 'with ProjectFile', :club_20s, :club_10s do
378
- FileUtils.copy(File.join(@testdir, 'spec/fixtures/ProjectFiles/only_meta.yaml'), 'test.murano')
362
+ FileUtils.copy(
363
+ File.join(@testdir, 'spec/fixtures/ProjectFiles/only_meta.yaml',),
364
+ 'test.murano',
365
+ )
379
366
  # The test account will have one business, one product, and one application.
380
367
  # So it won't ask any questions.
381
- out, err, status = Open3.capture3(capcmd('murano', 'init'))
368
+ out, err = murano_command_run('init')
382
369
  expected = expected_response_when_ids_found_in_config(
383
370
  self,
384
371
  expect_rebasing: true,
@@ -388,7 +375,6 @@ RSpec.describe 'murano init', :cmd do
388
375
  out_lines = out.lines.map { |line| strip_fancy(line) }
389
376
  expect(out_lines).to match_array(expected)
390
377
  expect(err).to eq('')
391
- expect(status.exitstatus).to eq(0)
392
378
 
393
379
  expect(File.directory?('.murano')).to be true
394
380
  expect(File.exist?('.murano/config')).to be true
@@ -419,7 +405,7 @@ RSpec.describe 'murano init', :cmd do
419
405
  # So it won't ask any questions.
420
406
  # NOTE: This tests uses an old Solutionfile.json, config v0.2.0, and it
421
407
  # downloads Lua scripts to the root of the project directory. Just FYI.
422
- out, err, status = Open3.capture3(capcmd('murano', 'init'))
408
+ out, err = murano_command_run('init')
423
409
  expected = expected_response_when_ids_found_in_config(
424
410
  self,
425
411
  expect_rebasing: true,
@@ -428,7 +414,6 @@ RSpec.describe 'murano init', :cmd do
428
414
  out_lines = out.lines.map { |line| strip_fancy(line) }
429
415
  expect(out_lines).to match_array(expected)
430
416
  expect(err).to eq('')
431
- expect(status.exitstatus).to eq(0)
432
417
 
433
418
  expect(File.directory?('.murano')).to be true
434
419
  expect(File.exist?('.murano/config')).to be true
@@ -458,7 +443,7 @@ RSpec.describe 'murano init', :cmd do
458
443
  end
459
444
  # The test account will have one business, one product, and one application.
460
445
  # So it won't ask any questions.
461
- out, err, status = Open3.capture3(capcmd('murano', 'init'))
446
+ out, err = murano_command_run('init')
462
447
  expected = expected_response_when_ids_found_in_config(
463
448
  self,
464
449
  expect_rebasing: true,
@@ -467,7 +452,6 @@ RSpec.describe 'murano init', :cmd do
467
452
  out_lines = out.lines.map { |line| strip_fancy(line) }
468
453
  expect(out_lines).to match_array(expected)
469
454
  expect(err).to eq('')
470
- expect(status.exitstatus).to eq(0)
471
455
 
472
456
  expect(File.directory?('.murano')).to be true
473
457
  expect(File.exist?('.murano/config')).to be true