MuranoCLI 2.2.4 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. checksums.yaml +4 -4
  2. data/.agignore +3 -0
  3. data/.gitignore +18 -1
  4. data/.rubocop.yml +222 -0
  5. data/.trustme.sh +185 -0
  6. data/.trustme.vim +24 -0
  7. data/Gemfile +23 -4
  8. data/LICENSE.txt +1 -1
  9. data/MuranoCLI.gemspec +43 -8
  10. data/README.markdown +9 -11
  11. data/Rakefile +187 -143
  12. data/TODO.taskpaper +2 -2
  13. data/bin/murano +51 -52
  14. data/docs/basic_example.rst +436 -0
  15. data/docs/completions/murano_completion-bash +3484 -0
  16. data/docs/demo.md +32 -32
  17. data/docs/develop.rst +391 -0
  18. data/lib/MrMurano.rb +21 -7
  19. data/lib/MrMurano/Account.rb +159 -174
  20. data/lib/MrMurano/Business.rb +381 -0
  21. data/lib/MrMurano/Config-Migrate.rb +32 -26
  22. data/lib/MrMurano/Config.rb +407 -128
  23. data/lib/MrMurano/Content.rb +191 -0
  24. data/lib/MrMurano/Gateway.rb +489 -0
  25. data/lib/MrMurano/Keystore.rb +48 -0
  26. data/lib/MrMurano/Passwords.rb +103 -0
  27. data/lib/MrMurano/ProjectFile.rb +121 -79
  28. data/lib/MrMurano/ReCommander.rb +114 -10
  29. data/lib/MrMurano/Setting.rb +90 -0
  30. data/lib/MrMurano/Solution-ServiceConfig.rb +89 -45
  31. data/lib/MrMurano/Solution-Services.rb +461 -166
  32. data/lib/MrMurano/Solution-Users.rb +70 -31
  33. data/lib/MrMurano/Solution.rb +372 -13
  34. data/lib/MrMurano/SolutionId.rb +73 -0
  35. data/lib/MrMurano/SyncRoot.rb +137 -0
  36. data/lib/MrMurano/SyncUpDown.rb +594 -284
  37. data/lib/MrMurano/Webservice-Cors.rb +71 -0
  38. data/lib/MrMurano/Webservice-Endpoint.rb +234 -0
  39. data/lib/MrMurano/Webservice-File.rb +193 -0
  40. data/lib/MrMurano/Webservice.rb +51 -0
  41. data/lib/MrMurano/commands.rb +18 -15
  42. data/lib/MrMurano/commands/business.rb +300 -6
  43. data/lib/MrMurano/commands/completion-bash.erb +166 -0
  44. data/lib/MrMurano/commands/{zshcomplete.erb → completion-zsh.erb} +0 -0
  45. data/lib/MrMurano/commands/completion.rb +76 -39
  46. data/lib/MrMurano/commands/config.rb +108 -44
  47. data/lib/MrMurano/commands/content.rb +115 -72
  48. data/lib/MrMurano/commands/cors.rb +29 -14
  49. data/lib/MrMurano/commands/devices.rb +286 -0
  50. data/lib/MrMurano/commands/domain.rb +52 -12
  51. data/lib/MrMurano/commands/gb.rb +24 -9
  52. data/lib/MrMurano/commands/globals.rb +64 -0
  53. data/lib/MrMurano/commands/init.rb +377 -155
  54. data/lib/MrMurano/commands/keystore.rb +92 -82
  55. data/lib/MrMurano/commands/link.rb +300 -0
  56. data/lib/MrMurano/commands/login.rb +74 -11
  57. data/lib/MrMurano/commands/logs.rb +63 -32
  58. data/lib/MrMurano/commands/mock.rb +57 -29
  59. data/lib/MrMurano/commands/password.rb +57 -39
  60. data/lib/MrMurano/commands/postgresql.rb +127 -94
  61. data/lib/MrMurano/commands/settings.rb +203 -0
  62. data/lib/MrMurano/commands/show.rb +79 -38
  63. data/lib/MrMurano/commands/solution.rb +423 -5
  64. data/lib/MrMurano/commands/solution_picker.rb +547 -0
  65. data/lib/MrMurano/commands/status.rb +195 -61
  66. data/lib/MrMurano/commands/sync.rb +78 -39
  67. data/lib/MrMurano/commands/timeseries.rb +71 -55
  68. data/lib/MrMurano/commands/tsdb.rb +113 -87
  69. data/lib/MrMurano/commands/usage.rb +57 -15
  70. data/lib/MrMurano/hash.rb +100 -10
  71. data/lib/MrMurano/http.rb +187 -43
  72. data/lib/MrMurano/makePretty.rb +16 -14
  73. data/lib/MrMurano/optparse.rb +2178 -0
  74. data/lib/MrMurano/progress.rb +138 -0
  75. data/lib/MrMurano/schema/resource-v1.0.0.yaml +32 -0
  76. data/lib/MrMurano/template/projectFile.murano.erb +16 -13
  77. data/lib/MrMurano/verbosing.rb +166 -29
  78. data/lib/MrMurano/version.rb +30 -1
  79. data/spec/Account-Passwords_spec.rb +21 -4
  80. data/spec/Account_spec.rb +69 -146
  81. data/spec/Business_spec.rb +290 -0
  82. data/spec/ConfigFile_spec.rb +1 -0
  83. data/spec/ConfigMigrate_spec.rb +12 -8
  84. data/spec/Config_spec.rb +40 -34
  85. data/spec/Content_spec.rb +363 -0
  86. data/spec/GatewayBase_spec.rb +54 -0
  87. data/spec/GatewayDevice_spec.rb +321 -0
  88. data/spec/GatewayResource_spec.rb +266 -0
  89. data/spec/GatewaySettings_spec.rb +120 -0
  90. data/spec/Http_spec.rb +18 -8
  91. data/spec/Mock_spec.rb +2 -2
  92. data/spec/ProjectFile_spec.rb +25 -14
  93. data/spec/Setting_spec.rb +110 -0
  94. data/spec/Solution-ServiceConfig_spec.rb +44 -5
  95. data/spec/Solution-ServiceEventHandler_spec.rb +23 -14
  96. data/spec/Solution-ServiceModules_spec.rb +47 -37
  97. data/spec/Solution-UsersRoles_spec.rb +10 -8
  98. data/spec/Solution_spec.rb +17 -8
  99. data/spec/SyncRoot_spec.rb +46 -20
  100. data/spec/SyncUpDown_spec.rb +437 -201
  101. data/spec/Verbosing_spec.rb +12 -4
  102. data/spec/{Solution-Cors_spec.rb → Webservice-Cors_spec.rb} +23 -20
  103. data/spec/{Solution-Endpoint_spec.rb → Webservice-Endpoint_spec.rb} +43 -41
  104. data/spec/{Solution-File_spec.rb → Webservice-File_spec.rb} +44 -33
  105. data/spec/Webservice-Setting_spec.rb +89 -0
  106. data/spec/_workspace.rb +4 -4
  107. data/spec/cmd_business_spec.rb +9 -4
  108. data/spec/cmd_common.rb +44 -1
  109. data/spec/cmd_content_spec.rb +43 -17
  110. data/spec/cmd_cors_spec.rb +4 -4
  111. data/spec/cmd_device_spec.rb +61 -16
  112. data/spec/cmd_domain_spec.rb +29 -6
  113. data/spec/cmd_init_spec.rb +281 -126
  114. data/spec/cmd_keystore_spec.rb +3 -3
  115. data/spec/cmd_link_spec.rb +98 -0
  116. data/spec/cmd_password_spec.rb +1 -1
  117. data/spec/cmd_setting_application_spec.rb +260 -0
  118. data/spec/cmd_setting_product_spec.rb +220 -0
  119. data/spec/cmd_status_spec.rb +223 -114
  120. data/spec/cmd_syncdown_spec.rb +115 -35
  121. data/spec/cmd_syncup_spec.rb +68 -15
  122. data/spec/cmd_usage_spec.rb +35 -8
  123. data/spec/fixtures/dumped_config +6 -4
  124. data/spec/fixtures/gateway_resource_files/resources.notyaml +12 -0
  125. data/spec/fixtures/gateway_resource_files/resources.yaml +13 -0
  126. data/spec/fixtures/gateway_resource_files/resources_invalid.yaml +13 -0
  127. data/spec/fixtures/mrmuranorc_deleted_bob +0 -2
  128. data/spec/fixtures/product_spec_files/lightbulb.yaml +20 -13
  129. data/spec/fixtures/{syncable_content → syncable_conflict}/services/devdata.lua +1 -1
  130. data/spec/fixtures/{syncable_content → syncable_conflict}/services/timers.lua +0 -0
  131. data/spec/spec_helper.rb +5 -0
  132. metadata +262 -171
  133. data/bin/mr +0 -8
  134. data/lib/MrMurano/Product-1P-Device.rb +0 -145
  135. data/lib/MrMurano/Product-Resources.rb +0 -205
  136. data/lib/MrMurano/Product.rb +0 -358
  137. data/lib/MrMurano/Solution-Cors.rb +0 -47
  138. data/lib/MrMurano/Solution-Endpoint.rb +0 -191
  139. data/lib/MrMurano/Solution-File.rb +0 -166
  140. data/lib/MrMurano/commands/assign.rb +0 -57
  141. data/lib/MrMurano/commands/businessList.rb +0 -45
  142. data/lib/MrMurano/commands/product.rb +0 -14
  143. data/lib/MrMurano/commands/productCreate.rb +0 -39
  144. data/lib/MrMurano/commands/productDelete.rb +0 -33
  145. data/lib/MrMurano/commands/productDevice.rb +0 -87
  146. data/lib/MrMurano/commands/productDeviceIdCmds.rb +0 -89
  147. data/lib/MrMurano/commands/productList.rb +0 -45
  148. data/lib/MrMurano/commands/productWrite.rb +0 -27
  149. data/lib/MrMurano/commands/solutionCreate.rb +0 -41
  150. data/lib/MrMurano/commands/solutionDelete.rb +0 -34
  151. data/lib/MrMurano/commands/solutionList.rb +0 -45
  152. data/spec/ProductBase_spec.rb +0 -113
  153. data/spec/ProductContent_spec.rb +0 -162
  154. data/spec/ProductResources_spec.rb +0 -329
  155. data/spec/Product_1P_Device_spec.rb +0 -202
  156. data/spec/Product_1P_RPC_spec.rb +0 -175
  157. data/spec/Product_spec.rb +0 -153
  158. data/spec/Solution-ServiceDevice_spec.rb +0 -176
  159. data/spec/cmd_assign_spec.rb +0 -51
@@ -1,3 +1,10 @@
1
+ # Last Modified: 2017.08.16 /coding: utf-8
2
+ # frozen_string_literal: probably not yet
3
+
4
+ # Copyright © 2016-2017 Exosite LLC.
5
+ # License: MIT. See LICENSE.txt.
6
+ # vim:tw=0:ts=2:sw=2:et:ai
7
+
1
8
  require 'fileutils'
2
9
  require 'open3'
3
10
  require 'pathname'
@@ -7,14 +14,23 @@ RSpec.describe 'murano domain', :cmd, :needs_password do
7
14
  include_context "CI_CMD"
8
15
 
9
16
  before(:example) do
10
- @project_name = rname('domainTest')
11
- out, err, status = Open3.capture3(capcmd('murano', 'solution', 'create', @project_name, '--save'))
17
+ @product_name = rname('domainTest')
18
+ out, err, status = Open3.capture3(capcmd('murano', 'product', 'create', @product_name, '--save'))
19
+ expect(err).to eq('')
20
+ expect(out.chomp).to match(/^[a-zA-Z0-9]+$/)
21
+ expect(status.exitstatus).to eq(0)
22
+ out, err, status = Open3.capture3(capcmd('murano', 'application', 'create', @product_name, '--save'))
12
23
  expect(err).to eq('')
13
24
  expect(out.chomp).to match(/^[a-zA-Z0-9]+$/)
14
25
  expect(status.exitstatus).to eq(0)
15
26
  end
27
+
16
28
  after(:example) do
17
- out, err, status = Open3.capture3(capcmd('murano', 'solution', 'delete', @project_name))
29
+ out, err, status = Open3.capture3(capcmd('murano', 'product', 'delete', @product_name, '-y'))
30
+ expect(out).to eq('')
31
+ expect(err).to eq('')
32
+ expect(status.exitstatus).to eq(0)
33
+ out, err, status = Open3.capture3(capcmd('murano', 'application', 'delete', @product_name, '--yes'))
18
34
  expect(out).to eq('')
19
35
  expect(err).to eq('')
20
36
  expect(status.exitstatus).to eq(0)
@@ -22,11 +38,18 @@ RSpec.describe 'murano domain', :cmd, :needs_password do
22
38
 
23
39
  it "show domain" do
24
40
  out, err, status = Open3.capture3(capcmd('murano', 'domain'))
25
- expect(out.chomp).to eq("#{@project_name.downcase}.apps.exosite.io")
41
+ # 2017-05-31: Previously, the project could be named whatever and
42
+ # the URI would start with the same.
43
+ # expect(out.chomp).to start_with("#{@product_name.downcase}.apps.exosite").and end_with(".io")
44
+ # Now, it's: <ID>.m2.exosite.io, where ID is of the form, "j41fj45hhk82so0os"
45
+ # Is there an expected length? [lb] has seen {16,17}
46
+ #expect(out.split('.', 2)[0]).to match(/^[a-zA-Z0-9]{16,17}$/)
47
+ #expect(out.chomp).to end_with("m2.exosite.io")
48
+ out.lines.each do |line|
49
+ expect(line).to match(/^(Product|Application): domain[Tt]est[a-z0-9]+ <[a-z0-9]+> https:\/\/[.a-z0-9]+$/)
50
+ end
26
51
  expect(err).to eq('')
27
52
  expect(status.exitstatus).to eq(0)
28
53
  end
29
-
30
54
  end
31
55
 
32
- # vim: set ai et sw=2 ts=2 :
@@ -1,16 +1,157 @@
1
+ # Last Modified: 2017.08.16 /coding: utf-8
2
+ # frozen_string_literal: true
3
+
4
+ # Copyright © 2016-2017 Exosite LLC.
5
+ # License: MIT. See LICENSE.txt.
6
+ # vim:tw=0:ts=2:sw=2:et:ai
7
+
1
8
  require 'fileutils'
2
9
  require 'open3'
3
10
  require 'pathname'
4
11
  require 'cmd_common'
5
12
 
6
- RSpec.describe 'mr init', :cmd do
13
+ RSpec.describe 'murano init', :cmd do
7
14
  include_context "CI_CMD"
8
15
 
16
+ def expectedResponseWhenIdsFoundInConfig(
17
+ t,
18
+ expect_rebasing: false,
19
+ has_one_each_soln: false,
20
+ has_no_solutions: false,
21
+ expect_proj_file_write: true,
22
+ creates_some_default_directories: false,
23
+ local_files_found: false,
24
+ local_files_found_application: false,
25
+ local_files_found_product: false
26
+ )
27
+ expecting = []
28
+ expecting += [
29
+ "\n", # 0
30
+ ]
31
+ if !expect_rebasing
32
+ expecting += [
33
+ t.a_string_starting_with('Creating project at '), # 1
34
+ ]
35
+ else
36
+ expecting += [
37
+ t.a_string_starting_with('Rebasing project at '), # 1
38
+ ]
39
+ end
40
+ expecting += [
41
+ "\n", # 2
42
+ t.a_string_starting_with('Found User '), # 3
43
+ "\n", # 4
44
+ t.a_string_starting_with('Found Business '), # 5
45
+ "\n", # 6
46
+ ]
47
+ if has_one_each_soln
48
+ expecting += [
49
+ a_string_starting_with('This business has one Application. Using '), # 7
50
+ "\n", # 8
51
+ a_string_starting_with('This business has one Product. Using '), # 9
52
+ "\n", # 10
53
+ ]
54
+ elsif has_no_solutions
55
+ # 2017-07-05: line numbers are for: context "without", :needs_password do / it "existing project" do
56
+ expecting += [
57
+ "This business does not have any applications. Let's create one\n", # 7
58
+ "\n", # 8
59
+ "Please enter the Application name: \n", # 9
60
+ a_string_starting_with('Created new Application: '), # 10
61
+ "\n", # 11
62
+ "This business does not have any products. Let's create one\n", # 12
63
+ "\n", # 13
64
+ "Please enter the Product name: \n", # 14
65
+ a_string_starting_with('Created new Product: '), # 15
66
+ "\n", # 16
67
+ ]
68
+ else
69
+ expecting += [
70
+ t.a_string_starting_with('Found Application '), # 7
71
+ "\n", # 8
72
+ t.a_string_starting_with('Found Product '), # 9
73
+ "\n", # 10
74
+ ]
75
+ end
76
+ expecting += [
77
+ t.a_string_matching(%r{Linked ‘\w+’ to ‘\w+’\n}),
78
+ "\n",
79
+ t.a_string_matching(%r{Created default event handler\n}),
80
+ "\n",
81
+ ]
82
+ if expect_proj_file_write
83
+ expecting += [
84
+ "Writing Project file to project.murano\n",
85
+ "\n",
86
+ ]
87
+ end
88
+ if !creates_some_default_directories
89
+ expecting += [
90
+ "Created default directories\n",
91
+ ]
92
+ else
93
+ expecting += [
94
+ "Created some default directories\n",
95
+ ]
96
+ end
97
+ expecting += [
98
+ "\n",
99
+ ]
100
+ if local_files_found || local_files_found_application
101
+ expecting += [
102
+ "Skipping Application Event Handlers: local files found\n",
103
+ "\n",
104
+ ]
105
+ end
106
+ if local_files_found || local_files_found_product
107
+ expecting += [
108
+ "Skipping Product Event Handlers: local files found\n",
109
+ "\n",
110
+ ]
111
+ end
112
+ #expecting += [
113
+ # t.a_string_matching(%r{Adding item \w+_event\n}),
114
+ # # Order not consistent...
115
+ # #"Adding item tsdb_exportJob\n",
116
+ # #"Adding item timer_timer\n",
117
+ # #"Adding item user_account\n",
118
+ # t.a_string_starting_with('Adding item '),
119
+ # t.a_string_starting_with('Adding item '),
120
+ # t.a_string_starting_with('Adding item '),
121
+ # "Synced 4 items\n",
122
+ # "\n",
123
+ #]
124
+ expecting += [
125
+ "Items already synced\n",
126
+ "\n",
127
+ ]
128
+ expecting += [
129
+ "Success!\n",
130
+ "\n",
131
+ t.a_string_matching(%r{\s+Business ID: \w+\n}),
132
+ t.a_string_matching(%r{(\s+Application ID: \w+\n)?}),
133
+ t.a_string_matching(%r{(\s+Product ID: \w+\n)?}),
134
+ "\n",
135
+ ]
136
+ expecting
137
+ end
138
+
139
+ def murano_solutions_expunge_yes
140
+ out, err, status = Open3.capture3(capcmd('murano', 'solutions', 'expunge', '-y'))
141
+ expect(out).to eq('').
142
+ or eq("No solutions found\n").
143
+ or eq("Deleted 1 solution\n").
144
+ or eq("Deleted 2 solutions\n")
145
+ expect(err).to eq('').
146
+ or eq("\e[31mNo solutions found\e[0m\n")
147
+ expect(status.exitstatus).to eq(0).or eq(1)
148
+ end
149
+
9
150
  it "Won't init in HOME (gracefully)" do
10
151
  # this is in the project dir. Want to be in HOME
11
152
  Dir.chdir(ENV['HOME']) do
12
153
  out, err, status = Open3.capture3(capcmd('murano', 'init'))
13
- expect(out).to eq("\n")
154
+ expect(out).to eq("")
14
155
  expect(err).to eq("\e[31mCannot init a project in your HOME directory.\e[0m\n")
15
156
  expect(status.exitstatus).to eq(2)
16
157
  end
@@ -18,17 +159,20 @@ RSpec.describe 'mr init', :cmd do
18
159
 
19
160
  context "in empty directory", :needs_password do
20
161
  context "with" do
21
- # Setup a solution and product to use.
162
+ # Setup a product and application to use.
22
163
  # Doing this in a context with before&after so that after runs even when test
23
164
  # fails.
24
165
  before(:example) do
25
- @project_name = rname('initEmpty')
26
- out, err, status = Open3.capture3(capcmd('murano', 'solution', 'create', @project_name, '--save'))
166
+ murano_solutions_expunge_yes
167
+
168
+ @applctn_name = rname('initEmptyApp')
169
+ out, err, status = Open3.capture3(capcmd('murano', 'application', 'create', @applctn_name, '--save'))
27
170
  expect(err).to eq('')
28
171
  expect(out.chomp).to match(/^[a-zA-Z0-9]+$/)
29
172
  expect(status.exitstatus).to eq(0)
30
173
 
31
- out, err, status = Open3.capture3(capcmd('murano', 'product', 'create', @project_name, '--save'))
174
+ @product_name = rname('initEmptyPrd')
175
+ out, err, status = Open3.capture3(capcmd('murano', 'product', 'create', @product_name, '--save'))
32
176
  expect(err).to eq('')
33
177
  expect(out.chomp).to match(/^[a-zA-Z0-9]+$/)
34
178
  expect(status.exitstatus).to eq(0)
@@ -37,37 +181,28 @@ RSpec.describe 'mr init', :cmd do
37
181
  FileUtils.remove_entry('.murano')
38
182
  end
39
183
  after(:example) do
40
- out, err, status = Open3.capture3(capcmd('murano', 'solution', 'delete', @project_name))
184
+ out, err, status = Open3.capture3(capcmd('murano', 'solution', 'delete', @product_name, '-y'))
41
185
  expect(out).to eq('')
42
186
  expect(err).to eq('')
43
187
  expect(status.exitstatus).to eq(0)
44
188
 
45
- out, err, status = Open3.capture3(capcmd('murano', 'product', 'delete', @project_name))
189
+ out, err, status = Open3.capture3(capcmd('murano', 'solution', 'delete', @applctn_name, '-y'))
46
190
  expect(out).to eq('')
47
191
  expect(err).to eq('')
48
192
  expect(status.exitstatus).to eq(0)
49
193
  end
50
194
 
51
- it "existing solution and product" do
52
- # The test account will have one business, one product, and one solution.
195
+ it "existing project" do
196
+ # The test account will have one business, one product, and one application.
53
197
  # So it won't ask any questions.
54
198
  out, err, status = Open3.capture3(capcmd('murano', 'init'))
55
- expect(out.lines).to match_array([
56
- "\n",
57
- a_string_starting_with('Found project base directory at '),
58
- "\n",
59
- a_string_starting_with('Using account '),
60
- a_string_starting_with('Using Business ID already set to '),
61
- "\n",
62
- a_string_starting_with('You only have one solution; using '),
63
- "\n",
64
- a_string_starting_with('You only have one product; using '),
65
- "\n",
66
- a_string_matching(%r{Ok, In business ID: \w+ using Solution ID: \w+ with Product ID: \w+}),
67
- "Writing an initial Project file: project.murano\n",
68
- "Default directories created\n",
69
- ])
70
- expect(err).to eq("")
199
+ expecting = expectedResponseWhenIdsFoundInConfig(
200
+ self,
201
+ has_one_each_soln: true,
202
+ )
203
+ out_lines = out.lines.map { |line| line.encode!('UTF-8', 'UTF-8') }
204
+ expect(out_lines).to match_array(expecting)
205
+ expect(err).to eq('')
71
206
  expect(status.exitstatus).to eq(0)
72
207
 
73
208
  expect(File.directory?(".murano")).to be true
@@ -82,44 +217,73 @@ RSpec.describe 'mr init', :cmd do
82
217
 
83
218
  context "without", :needs_password do
84
219
  before(:example) do
85
- @project_name = rname('initCreating')
220
+ murano_solutions_expunge_yes
221
+ @applctn_name = rname('initCreatingApp')
222
+ @product_name = rname('initCreatingPrd')
86
223
  end
87
224
  after(:example) do
88
- out, err, status = Open3.capture3(capcmd('murano', 'solution', 'delete', @project_name))
225
+ out, err, status = Open3.capture3(capcmd('murano', 'solution', 'delete', @product_name, '-y'))
89
226
  expect(out).to eq('')
90
227
  expect(err).to eq('')
91
228
  expect(status.exitstatus).to eq(0)
92
229
 
93
- out, err, status = Open3.capture3(capcmd('murano', 'product', 'delete', @project_name))
230
+ out, err, status = Open3.capture3(capcmd('murano', 'solution', 'delete', @applctn_name, '-y'))
94
231
  expect(out).to eq('')
95
232
  expect(err).to eq('')
96
233
  expect(status.exitstatus).to eq(0)
97
234
  end
98
235
 
99
- it "existing solution and product" do
236
+ it "existing project" do
100
237
  # The test account will have one business.
101
- # It will ask to create a solution and product.
102
- # !!!! the 8 is hardcoded indention here !!!!
238
+ # It will ask to create an application and product.
239
+ # MAGIC_NUMBER: !!!! the 8 is hardcoded indention here !!!!
240
+ # (removes the leading whitespace from the <<-EOT heredoc)
103
241
  data = <<-EOT.gsub(/^ {8}/, '')
104
- #{@project_name}
105
- #{@project_name}
242
+ #{@applctn_name}
243
+ #{@product_name}
106
244
  EOT
107
- out, err, status = Open3.capture3(capcmd('murano', 'init'), :stdin_data=>data)
108
- expect(out.lines).to match_array([
109
- "\n",
110
- a_string_starting_with('Found project base directory at '),
111
- "\n",
112
- a_string_starting_with('Using account '),
113
- a_string_starting_with('Using Business ID already set to '),
114
- "\n",
115
- "You don't have any solutions; lets create one\n",
116
- "Solution Name? \n",
117
- "You don't have any products; lets create one\n",
118
- "Product Name? \n",
119
- a_string_matching(%r{Ok, In business ID: \w+ using Solution ID: \w+ with Product ID: \w+}),
120
- "Writing an initial Project file: project.murano\n",
121
- "Default directories created\n",
122
- ])
245
+ # 2017-07-05: [lb] added line numbers to use debugger to help maintain this test.
246
+ out, err, status = Open3.capture3(capcmd('murano', 'init'), stdin_data: data)
247
+ expecting = expectedResponseWhenIdsFoundInConfig(
248
+ self,
249
+ has_no_solutions: true,
250
+ expect_proj_file_write: true,
251
+ )
252
+ out_lines = out.lines.map { |line| line.encode!('UTF-8', 'UTF-8') }
253
+ expect(out_lines).to match_array(expecting)
254
+ #expect(out.lines).to match_array([
255
+ # "\n", # 0
256
+ # a_string_starting_with('Creating project at '), # 1
257
+ # "\n", # 2
258
+ # a_string_starting_with('Found User '), # 3
259
+ # "\n", # 4
260
+ # a_string_starting_with('Found Business '), # 5
261
+ # "\n", # 6
262
+ # "This business does not have any applications. Let's create one\n", # 7
263
+ # "\n", # 8
264
+ # "Please enter the Application name: \n", # 9
265
+ # a_string_starting_with('Created new Application: '), # 10
266
+ # "\n", # 11
267
+ # "This business does not have any products. Let's create one\n", # 12
268
+ # "\n", # 13
269
+ # "Please enter the Product name: \n", # 14
270
+ # a_string_starting_with('Created new Product: '), # 15
271
+ # "\n", # 16
272
+ # a_string_starting_with('Linked ‘'), # 17
273
+ # "\n", # 18
274
+ # "Created default event handler\n", # 19
275
+ # "\n", # 20
276
+ # "Writing Project file to project.murano\n", # 21
277
+ # "\n", # 22
278
+ # "Created default directories\n", # 23
279
+ # "\n", # 24
280
+ # "Success!\n", # 25
281
+ # "\n", # 26
282
+ # a_string_starting_with(' Business ID: '), # 27
283
+ # a_string_starting_with(' Application ID: '), # 28
284
+ # a_string_starting_with(' Product ID: '), # 29
285
+ # "\n", # 30
286
+ #])
123
287
  expect(err).to eq("")
124
288
  expect(status.exitstatus).to eq(0)
125
289
 
@@ -136,53 +300,55 @@ RSpec.describe 'mr init', :cmd do
136
300
 
137
301
  context "in existing project directory", :needs_password do
138
302
  before(:example) do
303
+ murano_solutions_expunge_yes
304
+
139
305
  FileUtils.cp_r(File.join(@testdir, 'spec/fixtures/syncable_content/.'), '.')
140
- FileUtils.move('assets','files')
306
+ FileUtils.move('assets', 'files')
141
307
 
142
- @project_name = rname('initEmpty')
143
- out, err, status = Open3.capture3(capcmd('murano', 'solution', 'create', @project_name, '--save'))
308
+ @applctn_name = rname('initEmptyApp')
309
+ out, err, status = Open3.capture3(capcmd('murano', 'application', 'create', @applctn_name, '--save'))
144
310
  expect(err).to eq('')
145
311
  expect(out.chomp).to match(/^[a-zA-Z0-9]+$/)
146
312
  expect(status.exitstatus).to eq(0)
147
313
 
148
- out, err, status = Open3.capture3(capcmd('murano', 'product', 'create', @project_name, '--save'))
314
+ @product_name = rname('initEmptyPrd')
315
+ out, err, status = Open3.capture3(capcmd('murano', 'product', 'create', @product_name, '--save'))
149
316
  expect(err).to eq('')
150
317
  expect(out.chomp).to match(/^[a-zA-Z0-9]+$/)
151
318
  expect(status.exitstatus).to eq(0)
152
319
  end
153
320
  after(:example) do
154
321
  Dir.chdir(ENV['HOME']) do
155
- out, err, status = Open3.capture3(capcmd('murano', 'solution', 'delete', @project_name))
156
- expect(out).to eq('')
157
- expect(err).to eq('')
158
- expect(status.exitstatus).to eq(0)
322
+ if defined?(@product_name)
323
+ out, err, status = Open3.capture3(capcmd('murano', 'solution', 'delete', @product_name, '-y'))
324
+ expect(out).to eq('')
325
+ expect(err).to eq('')
326
+ expect(status.exitstatus).to eq(0)
327
+ end
159
328
 
160
- out, err, status = Open3.capture3(capcmd('murano', 'product', 'delete', @project_name))
161
- expect(out).to eq('')
162
- expect(err).to eq('')
163
- expect(status.exitstatus).to eq(0)
329
+ if defined?(@applctn_name)
330
+ out, err, status = Open3.capture3(capcmd('murano', 'solution', 'delete', @applctn_name, '-y'))
331
+ expect(out).to eq('')
332
+ expect(err).to eq('')
333
+ expect(status.exitstatus).to eq(0)
334
+ end
164
335
  end
165
336
  end
166
337
 
167
338
  it "without ProjectFile" do
168
- # The test account will have one business, one product, and one solution.
339
+ # The test account will have one business, one product, and one application.
169
340
  # So it won't ask any questions.
170
341
  out, err, status = Open3.capture3(capcmd('murano', 'init'))
171
- expect(out.lines).to match_array([
172
- "\n",
173
- a_string_starting_with('Found project base directory at '),
174
- "\n",
175
- a_string_starting_with('Using account '),
176
- a_string_starting_with('Using Business ID already set to '),
177
- "\n",
178
- a_string_starting_with('Using Solution ID already set to '),
179
- "\n",
180
- a_string_starting_with('Using Product ID already set to '),
181
- "\n",
182
- a_string_matching(%r{Ok, In business ID: \w+ using Solution ID: \w+ with Product ID: \w+}),
183
- "Writing an initial Project file: project.murano\n",
184
- "Default directories created\n",
185
- ])
342
+ the_expected = expectedResponseWhenIdsFoundInConfig(
343
+ self,
344
+ expect_rebasing: true,
345
+ creates_some_default_directories: true,
346
+ # Because the /tmp/murcli-test/services directory is empty,
347
+ # murano init *will* download all the event handlers.
348
+ #local_files_found: true,
349
+ )
350
+ out_lines = out.lines.map { |line| line.encode!('UTF-8', 'UTF-8') }
351
+ expect(out_lines).to match_array(the_expected)
186
352
  expect(err).to eq("")
187
353
  expect(status.exitstatus).to eq(0)
188
354
 
@@ -197,23 +363,20 @@ RSpec.describe 'mr init', :cmd do
197
363
 
198
364
  it "with ProjectFile" do
199
365
  FileUtils.copy(File.join(@testdir, 'spec/fixtures/ProjectFiles/only_meta.yaml'), 'test.murano')
200
- # The test account will have one business, one product, and one solution.
366
+ # The test account will have one business, one product, and one application.
201
367
  # So it won't ask any questions.
202
368
  out, err, status = Open3.capture3(capcmd('murano', 'init'))
203
- expect(out.lines).to match_array([
204
- "\n",
205
- a_string_starting_with('Found project base directory at '),
206
- "\n",
207
- a_string_starting_with('Using account '),
208
- a_string_starting_with('Using Business ID already set to '),
209
- "\n",
210
- a_string_starting_with('Using Solution ID already set to '),
211
- "\n",
212
- a_string_starting_with('Using Product ID already set to '),
213
- "\n",
214
- a_string_matching(%r{Ok, In business ID: \w+ using Solution ID: \w+ with Product ID: \w+}),
215
- "Default directories created\n",
216
- ])
369
+ expected = expectedResponseWhenIdsFoundInConfig(
370
+ self,
371
+ expect_rebasing: true,
372
+ expect_proj_file_write: false,
373
+ creates_some_default_directories: true,
374
+ # Because the /tmp/murcli-test/services directory is empty,
375
+ # murano init *will* download all the event handlers.
376
+ #local_files_found: true,
377
+ )
378
+ out_lines = out.lines.map { |line| line.encode!('UTF-8', 'UTF-8') }
379
+ expect(out_lines).to match_array(expected)
217
380
  expect(err).to eq("")
218
381
  expect(status.exitstatus).to eq(0)
219
382
 
@@ -242,24 +405,20 @@ RSpec.describe 'mr init', :cmd do
242
405
  }
243
406
  }.to_json
244
407
  end
245
- # The test account will have one business, one product, and one solution.
408
+ # The test account will have one business, one product, and one application.
246
409
  # So it won't ask any questions.
247
410
  out, err, status = Open3.capture3(capcmd('murano', 'init'))
248
- expect(out.lines).to match_array([
249
- "\n",
250
- a_string_starting_with('Found project base directory at '),
251
- "\n",
252
- a_string_starting_with('Using account '),
253
- a_string_starting_with('Using Business ID already set to '),
254
- "\n",
255
- a_string_starting_with('Using Solution ID already set to '),
256
- "\n",
257
- a_string_starting_with('Using Product ID already set to '),
258
- "\n",
259
- a_string_matching(%r{Ok, In business ID: \w+ using Solution ID: \w+ with Product ID: \w+}),
260
- "Writing an initial Project file: project.murano\n",
261
- "Default directories created\n",
262
- ])
411
+ expected = expectedResponseWhenIdsFoundInConfig(
412
+ self,
413
+ expect_rebasing: true,
414
+ creates_some_default_directories: true,
415
+ # Because the /tmp/murcli-test/services directory is empty,
416
+ # murano init *will* download all the event handlers.
417
+ ##local_files_found_application: true,
418
+ #local_files_found_product: true,
419
+ )
420
+ out_lines = out.lines.map { |line| line.encode!('UTF-8', 'UTF-8') }
421
+ expect(out_lines).to match_array(expected)
263
422
  expect(err).to eq("")
264
423
  expect(status.exitstatus).to eq(0)
265
424
 
@@ -289,24 +448,20 @@ RSpec.describe 'mr init', :cmd do
289
448
  :version => '0.3.0',
290
449
  }.to_json
291
450
  end
292
- # The test account will have one business, one product, and one solution.
451
+ # The test account will have one business, one product, and one application.
293
452
  # So it won't ask any questions.
294
453
  out, err, status = Open3.capture3(capcmd('murano', 'init'))
295
- expect(out.lines).to match_array([
296
- "\n",
297
- a_string_starting_with('Found project base directory at '),
298
- "\n",
299
- a_string_starting_with('Using account '),
300
- a_string_starting_with('Using Business ID already set to '),
301
- "\n",
302
- a_string_starting_with('Using Solution ID already set to '),
303
- "\n",
304
- a_string_starting_with('Using Product ID already set to '),
305
- "\n",
306
- a_string_matching(%r{Ok, In business ID: \w+ using Solution ID: \w+ with Product ID: \w+}),
307
- "Writing an initial Project file: project.murano\n",
308
- "Default directories created\n",
309
- ])
454
+ expected = expectedResponseWhenIdsFoundInConfig(
455
+ self,
456
+ expect_rebasing: true,
457
+ creates_some_default_directories: true,
458
+ # Because the /tmp/murcli-test/services directory is empty,
459
+ # murano init *will* download all the event handlers.
460
+ ##local_files_found_application: true,
461
+ #local_files_found_product: true,
462
+ )
463
+ out_lines = out.lines.map { |line| line.encode!('UTF-8', 'UTF-8') }
464
+ expect(out_lines).to match_array(expected)
310
465
  expect(err).to eq("")
311
466
  expect(status.exitstatus).to eq(0)
312
467
 
@@ -321,4 +476,4 @@ RSpec.describe 'mr init', :cmd do
321
476
  end
322
477
 
323
478
  end
324
- # vim: set ai et sw=2 ts=2 :
479
+