MuranoCLI 3.2.1.pre.beta.6 → 3.2.1.pre.beta.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (228) hide show
  1. checksums.yaml +4 -4
  2. data/HISTORY.md +10 -0
  3. data/MuranoCLI.gemspec +37 -6
  4. data/Rakefile +38 -11
  5. data/lib/MrMurano/commands/business.rb +0 -4
  6. data/lib/MrMurano/version.rb +1 -1
  7. metadata +2 -251
  8. data/dockers/Dockerfile.2.2.9 +0 -40
  9. data/dockers/Dockerfile.2.3.6 +0 -40
  10. data/dockers/Dockerfile.2.4.3 +0 -40
  11. data/dockers/Dockerfile.2.5.0 +0 -40
  12. data/dockers/Dockerfile.GemRelease +0 -49
  13. data/dockers/Dockerfile.m4 +0 -122
  14. data/dockers/README.rst +0 -362
  15. data/dockers/RELEASE.rst +0 -135
  16. data/dockers/docker-test.sh +0 -163
  17. data/dockers/gem-release.sh +0 -4
  18. data/docs/basic_example.rst +0 -436
  19. data/docs/ci/.trustme.plugin +0 -140
  20. data/docs/ci/.trustme.sh +0 -516
  21. data/docs/ci/.trustme.vim +0 -55
  22. data/docs/completions/murano_completion-bash +0 -4484
  23. data/docs/demo.md +0 -109
  24. data/docs/develop.rst +0 -392
  25. data/docs/release.rst +0 -295
  26. data/spec/Account-Passwords_spec.rb +0 -245
  27. data/spec/Account_spec.rb +0 -256
  28. data/spec/Business_spec.rb +0 -307
  29. data/spec/ConfigFile_spec.rb +0 -55
  30. data/spec/ConfigMigrate_spec.rb +0 -108
  31. data/spec/Config_spec.rb +0 -440
  32. data/spec/Content_spec.rb +0 -422
  33. data/spec/GatewayBase_spec.rb +0 -65
  34. data/spec/GatewayDevice_spec.rb +0 -403
  35. data/spec/GatewayResource_spec.rb +0 -283
  36. data/spec/GatewaySettings_spec.rb +0 -130
  37. data/spec/HttpAuthed_spec.rb +0 -87
  38. data/spec/Http_spec.rb +0 -220
  39. data/spec/MakePretties_spec.rb +0 -127
  40. data/spec/Mock_spec.rb +0 -62
  41. data/spec/ProjectFile_spec.rb +0 -381
  42. data/spec/Setting_spec.rb +0 -120
  43. data/spec/Solution-ServiceConfig_spec.rb +0 -272
  44. data/spec/Solution-ServiceEventHandler_spec.rb +0 -442
  45. data/spec/Solution-ServiceModules_spec.rb +0 -562
  46. data/spec/Solution-UsersRoles_spec.rb +0 -269
  47. data/spec/Solution_spec.rb +0 -140
  48. data/spec/SyncRoot_spec.rb +0 -111
  49. data/spec/SyncUpDown_spec.rb +0 -868
  50. data/spec/Verbosing_spec.rb +0 -332
  51. data/spec/Webservice-Cors_spec.rb +0 -225
  52. data/spec/Webservice-Endpoint_spec.rb +0 -650
  53. data/spec/Webservice-File_spec.rb +0 -282
  54. data/spec/Webservice-Setting_spec.rb +0 -105
  55. data/spec/_workspace.rb +0 -43
  56. data/spec/cmd_business_spec.rb +0 -64
  57. data/spec/cmd_common.rb +0 -507
  58. data/spec/cmd_config_spec.rb +0 -73
  59. data/spec/cmd_content_spec.rb +0 -109
  60. data/spec/cmd_cors_spec.rb +0 -54
  61. data/spec/cmd_device_spec.rb +0 -130
  62. data/spec/cmd_domain_spec.rb +0 -62
  63. data/spec/cmd_element_spec.rb +0 -401
  64. data/spec/cmd_exchange_spec.rb +0 -114
  65. data/spec/cmd_help_spec.rb +0 -72
  66. data/spec/cmd_init_spec.rb +0 -475
  67. data/spec/cmd_keystore_spec.rb +0 -97
  68. data/spec/cmd_link_spec.rb +0 -105
  69. data/spec/cmd_logs_spec.rb +0 -162
  70. data/spec/cmd_password_spec.rb +0 -64
  71. data/spec/cmd_setting_application_spec.rb +0 -300
  72. data/spec/cmd_setting_product_spec.rb +0 -246
  73. data/spec/cmd_status_spec.rb +0 -300
  74. data/spec/cmd_syncdown_application_spec.rb +0 -128
  75. data/spec/cmd_syncdown_both_spec.rb +0 -178
  76. data/spec/cmd_syncdown_unit_spec.rb +0 -861
  77. data/spec/cmd_syncup_spec.rb +0 -148
  78. data/spec/cmd_token_spec.rb +0 -53
  79. data/spec/cmd_usage_spec.rb +0 -79
  80. data/spec/dry_run_formatter.rb +0 -28
  81. data/spec/fixtures/.mrmuranorc +0 -9
  82. data/spec/fixtures/ProjectFiles/invalid.yaml +0 -9
  83. data/spec/fixtures/ProjectFiles/only_meta.yaml +0 -24
  84. data/spec/fixtures/ProjectFiles/with_routes.yaml +0 -27
  85. data/spec/fixtures/SolutionFiles/0.2.0.json +0 -20
  86. data/spec/fixtures/SolutionFiles/0.2.0_invalid.json +0 -18
  87. data/spec/fixtures/SolutionFiles/0.2.json +0 -21
  88. data/spec/fixtures/SolutionFiles/0.3.0.json +0 -20
  89. data/spec/fixtures/SolutionFiles/0.3.0_invalid.json +0 -19
  90. data/spec/fixtures/SolutionFiles/0.3.json +0 -20
  91. data/spec/fixtures/SolutionFiles/basic.json +0 -20
  92. data/spec/fixtures/SolutionFiles/secret.json +0 -6
  93. data/spec/fixtures/configfile +0 -9
  94. data/spec/fixtures/dumped_config +0 -57
  95. data/spec/fixtures/exchange_element/element-show.json +0 -1
  96. data/spec/fixtures/exchange_element/swagger-mur-6407__10k.yaml +0 -282
  97. data/spec/fixtures/exchange_element/swagger-mur-6407__20k.yaml +0 -588
  98. data/spec/fixtures/gateway_resource_files/resources.notyaml +0 -12
  99. data/spec/fixtures/gateway_resource_files/resources.yaml +0 -13
  100. data/spec/fixtures/gateway_resource_files/resources_invalid.yaml +0 -13
  101. data/spec/fixtures/mrmuranorc_deleted_bob +0 -6
  102. data/spec/fixtures/mrmuranorc_tool_bob +0 -3
  103. data/spec/fixtures/product_spec_files/example.exoline.spec.yaml +0 -116
  104. data/spec/fixtures/product_spec_files/example.murano.spec.yaml +0 -14
  105. data/spec/fixtures/product_spec_files/gwe.exoline.spec.yaml +0 -21
  106. data/spec/fixtures/product_spec_files/gwe.murano.spec.yaml +0 -16
  107. data/spec/fixtures/product_spec_files/lightbulb-no-state.yaml +0 -11
  108. data/spec/fixtures/product_spec_files/lightbulb.yaml +0 -21
  109. data/spec/fixtures/roles-three.yaml +0 -11
  110. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value 0.webmock +0 -98
  111. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value 1.webmock +0 -98
  112. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value No.webmock +0 -98
  113. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value Yes.webmock +0 -98
  114. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value bob.webmock +0 -72
  115. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value false.webmock +0 -98
  116. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value off.webmock +0 -98
  117. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value on STDIN.webmock +0 -98
  118. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value on.webmock +0 -98
  119. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value true.webmock +0 -98
  120. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a json array blob with STDIN.webmock +0 -98
  121. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a json array blob.webmock +0 -98
  122. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) an array.webmock +0 -98
  123. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) appends an array.webmock +0 -98
  124. data/spec/fixtures/snapshots/murano application setting reads Webservice.cors to a file.webmock +0 -72
  125. data/spec/fixtures/snapshots/murano application setting reads Webservice.cors.webmock +0 -72
  126. data/spec/fixtures/snapshots/murano business list as json.webmock +0 -27
  127. data/spec/fixtures/snapshots/murano business list as table.webmock +0 -27
  128. data/spec/fixtures/snapshots/murano business list fewer fields.webmock +0 -27
  129. data/spec/fixtures/snapshots/murano business list only ids.webmock +0 -27
  130. data/spec/fixtures/snapshots/murano business list output to file.webmock +0 -27
  131. data/spec/fixtures/snapshots/murano business without project help.webmock +0 -9
  132. data/spec/fixtures/snapshots/murano config Needs a key.webmock +0 -9
  133. data/spec/fixtures/snapshots/murano config Reads a key.webmock +0 -9
  134. data/spec/fixtures/snapshots/murano config Removes a key.webmock +0 -9
  135. data/spec/fixtures/snapshots/murano config Sets a key.webmock +0 -9
  136. data/spec/fixtures/snapshots/murano config Sets a user key.webmock +0 -9
  137. data/spec/fixtures/snapshots/murano content life cycle.webmock +0 -144
  138. data/spec/fixtures/snapshots/murano cors sets CORS.webmock +0 -78
  139. data/spec/fixtures/snapshots/murano cors show CORS.webmock +0 -64
  140. data/spec/fixtures/snapshots/murano device activates.webmock +0 -86
  141. data/spec/fixtures/snapshots/murano device enables a batch.webmock +0 -76
  142. data/spec/fixtures/snapshots/murano device enables and lists.webmock +0 -78
  143. data/spec/fixtures/snapshots/murano device writes and reads.webmock +0 -136
  144. data/spec/fixtures/snapshots/murano domain show domain.webmock +0 -101
  145. data/spec/fixtures/snapshots/murano element edit unknown as unknown element.webmock +0 -43
  146. data/spec/fixtures/snapshots/murano element show --help.webmock +0 -9
  147. data/spec/fixtures/snapshots/murano element show as csv.webmock +0 -43
  148. data/spec/fixtures/snapshots/murano element show as default-table.webmock +0 -43
  149. data/spec/fixtures/snapshots/murano element show as json.webmock +0 -43
  150. data/spec/fixtures/snapshots/murano element show as table truncate.webmock +0 -43
  151. data/spec/fixtures/snapshots/murano element show as table wrap.webmock +0 -43
  152. data/spec/fixtures/snapshots/murano element show as yaml.webmock +0 -43
  153. data/spec/fixtures/snapshots/murano element show using ambiguous name.webmock +0 -43
  154. data/spec/fixtures/snapshots/murano element without project usage.webmock +0 -9
  155. data/spec/fixtures/snapshots/murano exchange with project list as json.webmock +0 -59
  156. data/spec/fixtures/snapshots/murano exchange with project list as table.webmock +0 -59
  157. data/spec/fixtures/snapshots/murano exchange with project list fewer fields.webmock +0 -59
  158. data/spec/fixtures/snapshots/murano exchange with project list only ids.webmock +0 -59
  159. data/spec/fixtures/snapshots/murano exchange with project list output to file.webmock +0 -59
  160. data/spec/fixtures/snapshots/murano exchange with project list purchase is already added ID.webmock +0 -83
  161. data/spec/fixtures/snapshots/murano exchange with project list purchase is ambiguous name.webmock +0 -59
  162. data/spec/fixtures/snapshots/murano exchange without project help.webmock +0 -9
  163. data/spec/fixtures/snapshots/murano help using commander as --help.webmock +0 -9
  164. data/spec/fixtures/snapshots/murano help using commander no args.webmock +0 -9
  165. data/spec/fixtures/snapshots/murano help using subshell no args.webmock +0 -9
  166. data/spec/fixtures/snapshots/murano help using subshell with --help.webmock +0 -9
  167. data/spec/fixtures/snapshots/murano init Won't init in HOME (gracefully).webmock +0 -9
  168. data/spec/fixtures/snapshots/murano init in empty directory with existing project.webmock +0 -201
  169. data/spec/fixtures/snapshots/murano init in empty directory without existing project.webmock +0 -193
  170. data/spec/fixtures/snapshots/murano init in existing project directory with ProjectFile.webmock +0 -213
  171. data/spec/fixtures/snapshots/murano init in existing project directory with SolutionFile 0.2.0.webmock +0 -213
  172. data/spec/fixtures/snapshots/murano init in existing project directory with SolutionFile 0.3.0.webmock +0 -213
  173. data/spec/fixtures/snapshots/murano init in existing project directory without ProjectFile.webmock +0 -213
  174. data/spec/fixtures/snapshots/murano keystore can call other commands.webmock +0 -108
  175. data/spec/fixtures/snapshots/murano keystore clearAll.webmock +0 -124
  176. data/spec/fixtures/snapshots/murano keystore deletes.webmock +0 -112
  177. data/spec/fixtures/snapshots/murano keystore gets.webmock +0 -96
  178. data/spec/fixtures/snapshots/murano keystore infos.webmock +0 -96
  179. data/spec/fixtures/snapshots/murano keystore lists.webmock +0 -96
  180. data/spec/fixtures/snapshots/murano link with project links and lists.webmock +0 -149
  181. data/spec/fixtures/snapshots/murano link with project unlinks.webmock +0 -165
  182. data/spec/fixtures/snapshots/murano link without project help.webmock +0 -9
  183. data/spec/fixtures/snapshots/murano link without project subshell vs inline using commander will not list.webmock +0 -27
  184. data/spec/fixtures/snapshots/murano link without project subshell vs inline using subshell will not list.webmock +0 -27
  185. data/spec/fixtures/snapshots/murano logs when project is setup tail log.webmock +0 -9
  186. data/spec/fixtures/snapshots/murano password Lists when no file.webmock +0 -9
  187. data/spec/fixtures/snapshots/murano password deletes a password.webmock +0 -9
  188. data/spec/fixtures/snapshots/murano password sets a password.webmock +0 -9
  189. data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a forced string value on STDIN.webmock +0 -90
  190. data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a forced string value.webmock +0 -90
  191. data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a number value fiftyHalf.webmock +0 -64
  192. data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a number value float 12.67.webmock +0 -90
  193. data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a number value integer 12.webmock +0 -90
  194. data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a number value on STDIN.webmock +0 -90
  195. data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a string value.webmock +0 -90
  196. data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) merges into a dictionary.webmock +0 -90
  197. data/spec/fixtures/snapshots/murano single sync without ProjectFile syncdown.webmock +0 -322
  198. data/spec/fixtures/snapshots/murano status with ProjectFile status.webmock +0 -153
  199. data/spec/fixtures/snapshots/murano status with Solutionfile 0.2.0 status.webmock +0 -153
  200. data/spec/fixtures/snapshots/murano status with Solutionfile 0.3.0 status.webmock +0 -153
  201. data/spec/fixtures/snapshots/murano status without ProjectFile matches file path.webmock +0 -153
  202. data/spec/fixtures/snapshots/murano status without ProjectFile matches route.webmock +0 -153
  203. data/spec/fixtures/snapshots/murano status without ProjectFile status.webmock +0 -153
  204. data/spec/fixtures/snapshots/murano syncdown stubbed without ProjectFile syncdown.webmock +0 -151
  205. data/spec/fixtures/snapshots/murano syncdown without ProjectFile syncdown.webmock +0 -479
  206. data/spec/fixtures/snapshots/murano syncup without ProjectFile syncup.webmock +0 -357
  207. data/spec/fixtures/snapshots/murano token with project list as table.webmock +0 -9
  208. data/spec/fixtures/snapshots/murano token without project help.webmock +0 -9
  209. data/spec/fixtures/snapshots/murano usage show usage.webmock +0 -93
  210. data/spec/fixtures/syncable_conflict/services/devdata.lua +0 -18
  211. data/spec/fixtures/syncable_conflict/services/timers.lua +0 -4
  212. data/spec/fixtures/syncable_content/assets/icon.png +0 -0
  213. data/spec/fixtures/syncable_content/assets/index.html +0 -0
  214. data/spec/fixtures/syncable_content/assets/js/script.js +0 -0
  215. data/spec/fixtures/syncable_content/modules/table_util.lua +0 -58
  216. data/spec/fixtures/syncable_content/routes/manyRoutes.lua +0 -11
  217. data/spec/fixtures/syncable_content/routes/singleRoute.lua +0 -5
  218. data/spec/fixtures/websocket/README.rst +0 -110
  219. data/spec/fixtures/websocket/logs_blather.rb +0 -27
  220. data/spec/fixtures/websocket/logs_faker.rb +0 -153
  221. data/spec/fixtures/websocket/simple_connection.rb +0 -45
  222. data/spec/fixtures/websocket/simple_options.rb +0 -77
  223. data/spec/fixtures/websocket/simple_server.rb +0 -69
  224. data/spec/fixtures/websocket/wss-echo.rb +0 -48
  225. data/spec/fixtures/websocket/wss-fake-logs.rb +0 -20
  226. data/spec/spec_helper.rb +0 -131
  227. data/spec/variegated_TruthyFalsey_spec.rb +0 -29
  228. data/spec/webmock_snapshot.rb +0 -296
data/spec/cmd_common.rb DELETED
@@ -1,507 +0,0 @@
1
- # Copyright © 2016-2017 Exosite LLC. All Rights Reserved
2
- # License: PROPRIETARY. See LICENSE.txt.
3
- # frozen_string_literal: true
4
-
5
- # vim:tw=0:ts=2:sw=2:et:ai
6
- # Unauthorized copying of this file is strictly prohibited.
7
-
8
- require 'highline'
9
- # Set HighLine's $terminal global.
10
- require 'highline/import'
11
- require 'os'
12
- require 'pathname'
13
- require 'rainbow'
14
- require 'shellwords'
15
- require 'time'
16
- require 'timeout'
17
- require 'tmpdir'
18
- require 'webmock/rspec'
19
-
20
- require 'MrMurano/progress'
21
- require 'MrMurano/Config'
22
- require 'MrMurano/HttpAuthed'
23
-
24
- require 'webmock_snapshot'
25
-
26
- # Prevent Commander from registering its at_exit hook.
27
- # - Also print warning if spec exits, which rspec doesn't see as wrong.
28
- # - Note that this comes before importing Commander.
29
- $exited_abnormally = false
30
-
31
- $catpured_io = false
32
-
33
- def capture_stdio
34
- return if $catpured_io
35
- $murcli_wasin = $stdin # (lb): Could probably just use STDIN and skip this global.
36
- $murcli_wasout = $stdout
37
- $murcli_waserr = $stderr
38
- $murcli_wasterm = $terminal
39
- $catpured_io = true
40
- end
41
- capture_stdio
42
-
43
- def restore_stdio
44
- return unless $catpured_io
45
- $stdin = $murcli_wasin
46
- $stdout = $murcli_wasout
47
- $stderr = $murcli_waserr
48
- $terminal = $murcli_wasterm
49
- $murcli_wasin = nil
50
- $murcli_wasout = nil
51
- $murcli_waserr = nil
52
- $murcli_wasterm = nil
53
- $catpured_io = false
54
- end
55
-
56
- at_exit do
57
- if $exited_abnormally
58
- restore_stdio
59
- warn('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
60
- warn(%( ____ ))
61
- warn(%{ ,%( Y`. })
62
- warn(%( / \ ))
63
- warn(%( \ () () / ))
64
- warn(%{ `. /\ ,%( })
65
- warn(%( 8====| "" |====8 ))
66
- warn(%( `LLLU' ))
67
- warn(%( ))
68
- warn('¡Unexpected spec exit killed rspec!')
69
- warn('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
70
- # DEVs: If you see this message, the last test exited unexpectedly.
71
- warn('')
72
- warn("Died on: #{$exited_abnormally}")
73
- warn('')
74
- end
75
- end
76
- alias original_at_exit at_exit unless defined?(original_at_exit)
77
-
78
- def at_exit(*args, &block)
79
- #original_at_exit *args, &block
80
- # pass!
81
- end
82
-
83
- require 'MrMurano/Commander-Entry'
84
-
85
- module Commander
86
- class Command
87
- attr_writer :when_called
88
- #def when_called=(args)
89
- # @when_called = args
90
- #end
91
-
92
- def peek_when_called
93
- @when_called
94
- end
95
- end
96
-
97
- class Runner
98
- def force_args(args)
99
- @args = args
100
- end
101
- end
102
- end
103
-
104
- RSpec.shared_context 'CI_CMD' do
105
- # capcmd makes an Open3-ready `murano` command from a list of args.
106
- def capcmd(*args)
107
- args = [args] unless args.is_a? Array
108
- args.flatten!
109
- testdir = File.realpath(@testdir.to_s)
110
- if ENV['CI_MR_EXE'].nil?
111
- args[0] = File.join(testdir, 'bin', args[0])
112
- args.unshift('ruby', "-I#{File.join(testdir, 'lib')}")
113
- else
114
- args[0] = File.join(testdir, (args[0] + '.exe'))
115
- end
116
- args.push '--trace'
117
- args.push '-c', 'fullerror'
118
- # The spinner output would make it hard to write expects().
119
- args.push '--no-progress'
120
-
121
- # FIXME: (lb): Is this necessary? Commenting out for now; will delete later.
122
- ## Save the token.
123
- #args.push '--cache'
124
-
125
- if Gem.win_platform?
126
- cmd = args.map do |i|
127
- case i
128
- when /[ ]/
129
- %("#{i}")
130
- when /[\*#]/
131
- i.gsub(/([\*#])/, '^\1')
132
- else
133
- i
134
- end
135
- end.join(' ')
136
- else
137
- cmd = Shellwords.join(args)
138
- end
139
- #pp cmd
140
- cmd
141
- end
142
-
143
- # *** Utility fcns: symlinks.
144
-
145
- # Makes a symlink to the /tmp project dir.
146
- def mk_symlink
147
- # Make it easy to debug tests, e.g., add breakpoint before capcmd('murano', ...)
148
- # run test, then open another terminal window and `cd /tmp/murcli-test`.
149
- # NOTE: When run on Jenkins, Dir.tmpdir() returns the path to the project directory!
150
- # Since this is for DEVs only, we can hack around this.
151
- tmpdir = Dir.tmpdir()
152
- return unless tmpdir == '/tmp'
153
- @dev_symlink = File.join(tmpdir, 'murcli-test')
154
- FileUtils.rm(@dev_symlink, force: true)
155
- begin
156
- FileUtils.ln_s(Dir.pwd, @dev_symlink)
157
- rescue NotImplementedError => err
158
- # This happens on Windows...
159
- require 'rbconfig'
160
- # Check the platform, e.g., "linux-gnu", or other.
161
- #is_windows = (
162
- # RbConfig::CONFIG['host_os'] =~ /mswin|msys|mingw|cygwin|bccwin|wince|emc/
163
- #)
164
- unless OS.windows?
165
- warn(
166
- 'Unexpected: ln_s failed on non-Windows machine / ' \
167
- "host_os: #{RbConfig::CONFIG['host_os']} / err: #{err}"
168
- )
169
- end
170
- end
171
- end
172
-
173
- # Removes the /tmp project directory symlink.
174
- def rm_symlink
175
- FileUtils.rm(@dev_symlink, force: true) if defined?(@dev_symlink)
176
- end
177
-
178
- # *** Utility fcns: Murano Solutions management: create/delete/expunge.
179
-
180
- def murano_solutions_expunge_yes
181
- out, err = murano_command_safe('solutions expunge', '-y')
182
- expect(out).to \
183
- eq('').or \
184
- eq("No solutions found\n").or \
185
- match(/^Deleted [\d]+ solutions?/)
186
- expect(MrMurano::Progress.strip_color(err)).to eq('').or eq("No solutions found\n")
187
- end
188
-
189
- def project_up(skip_link: false)
190
- # Preemptive clean up!
191
- murano_solutions_expunge_yes if defined?(PRE_EXPUNGE) && PRE_EXPUNGE
192
-
193
- @proj_name_prod = @snapshotter.resolve_var(
194
- 'product.name', rname('MurCLITestProd')
195
- )
196
- # NOTE: Do not use alias, which resolves to base command, but without options.
197
- # E.g., use 'solution create', ...; and not 'product create'.
198
- out, err = murano_command_run(
199
- 'solution create', '--type', 'product', @proj_name_prod, '--save',
200
- )
201
- expect(err).to eq('')
202
- expect(out.chomp).to match(/^[a-zA-Z0-9]+$/)
203
-
204
- @proj_name_appy = @snapshotter.resolve_var(
205
- 'application.name', rname('MurCLITestAppy')
206
- )
207
- out, err = murano_command_run(
208
- 'solution create', '--type', 'application', @proj_name_appy, '--save',
209
- )
210
- expect(err).to eq('')
211
- soln_id = out
212
- expect(soln_id.chomp).to match(/^[a-zA-Z0-9]+$/)
213
-
214
- project_up_link unless skip_link
215
- end
216
-
217
- def project_up_link
218
- out, err = murano_command_run('assign set')
219
- olines = out.lines
220
- expect(strip_fancy(olines[0])).to eq(
221
- "Linked '#{@proj_name_prod}' to '#{@proj_name_appy}'\n"
222
- )
223
- expect(olines[1]).to eq("Created default event handler\n")
224
- expect(err).to eq('')
225
- end
226
-
227
- def project_down
228
- return if defined?(PRE_EXPUNGE) && PRE_EXPUNGE
229
-
230
- out, err = murano_command_run('solution delete', @proj_name_appy, '-y')
231
- expect(out).to eq('')
232
- expect(err).to eq('')
233
-
234
- out, err = murano_command_run('solution delete', @proj_name_prod, '-y')
235
- expect(out).to eq('')
236
- expect(err).to eq('')
237
- end
238
-
239
- # Utility fcns: Strings.
240
-
241
- # rname makes a random Murano-acceptable Solution name.
242
- def rname(name='')
243
- #"#{name}-#{Random.new.rand.hash.abs.to_s(16)}"
244
- # MUR-2454: Product name may only contain letters and numbers.
245
- #"#{name}#{Random.new.rand.hash.abs.to_s(16)}"
246
- # MUR-XXXX: Product name must be lowercase.
247
- # 2017-06-01: From [cr]: "I'll be having bizapi convert to lower case
248
- # in the short term, and pegasus is updating to allow upper case."
249
- # LATER: Remove .downcase once PAAS fixed.
250
- "#{name.downcase}#{Random.new.rand.hash.abs.to_s(16)}"
251
- end
252
-
253
- def strip_fancy(str)
254
- # Windows has a complaint about the fancy quotes if you don't encode!, which is
255
- #
256
- # expected: "Linked \u2018syncdowntestprd1e8b4034\u2019
257
- # to \u2018syncdowntestapp23d5135b\u2019\n"
258
- # got: "Linked \xE2\x80\x98syncdowntestprd1e8b4034\xE2\x80\x99
259
- # to \xE2\x80\x98syncdowntestapp23d5135b\xE2\x80\x99\n"
260
- #
261
- # or, to put it another way,
262
- #
263
- # -Linked ?syncdowntestprd1e8b4034? to ?syncdowntestapp23d5135b?
264
- # +Linked ΓÇÿsyncdowntestprd1e8b4034ΓÇÖ to ΓÇÿsyncdowntestapp23d5135bΓÇÖ
265
- #
266
- # which we can solve with an encode call. (Or but using norm quotes.)
267
- str.nil? && '' ||
268
- str.encode!(
269
- 'UTF-8', 'UTF-8'
270
- ).tr(%(‘), %(')).tr(%(’), %('))
271
- end
272
-
273
- # *** rb-commander goodies
274
-
275
- def murano_command_run(cmd, *args)
276
- murano_command_runner(cmd, *args)
277
- end
278
-
279
- def murano_command_run_gentle(cmd, *args)
280
- murano_command_runner(cmd, *args, skip_cfg: true)
281
- end
282
-
283
- def murano_command_exits(cmd, *args)
284
- murano_command_runner(cmd, *args, wont_run: true)
285
- end
286
-
287
- def murano_command_safe(cmd, *args)
288
- murano_command_runner(cmd, *args, wont_run: :unknown)
289
- end
290
-
291
- def murano_command_wont_parse(cmd, *args)
292
- murano_command_runner(cmd, *args, wont_parse: true)
293
- end
294
-
295
- def murano_command_runner(
296
- cmd, *args, wont_run: false, wont_parse: false, skip_cfg: false, stdin_data: nil
297
- )
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
309
-
310
- capture_stdio
311
- tmpout = StringIO.new
312
- tmperr = StringIO.new
313
-
314
- unless stdin_data.nil?
315
- $stdin = StringIO.new
316
- $stdin.print(stdin_data)
317
- $stdin.rewind
318
- end
319
-
320
- # Commander's `say` calls HighLine's $terminal.say, so redirect that, too.
321
- hline = HighLine.new($stdin, tmpout)
322
- $terminal = hline
323
- # DEVs: If you set a byebug break after this point, the byebug will
324
- # show when the code breaks, but you'll see no echo or output. So
325
- # comment this code out if you're debugging.
326
- $stdout = tmpout
327
- $stderr = tmperr
328
-
329
- $exited_abnormally = "#{cmd} #{args.join(' ')}"
330
-
331
- MrMurano::HttpAuthed.instance.credentials_reset
332
-
333
- # When Commander is loaded, it sets an at_exit hook, which we monkey
334
- # patch in ReCommander. Since Config.validate_cmd is called before
335
- # at_exit, it uses runner.command_exit to tell ReCommander's at_exit
336
- # monkey patch not to call Commander.run!. Via rspec, we don't use the
337
- # at_exit hook, or ReCommander.
338
- unless skip_cfg
339
- $cfg = MrMurano::Config.new(::Commander::Runner.instance)
340
- $cfg.load
341
- $cfg['tool.no-progress'] = true
342
-
343
- # In case the test runner installed a project file.
344
- $project = MrMurano::ProjectFile.new
345
- $project.load
346
- end
347
- $cfg.validate_cmd
348
-
349
- runner = ::Commander::Runner.instance
350
- unless defined?(runner.command_exit) && runner.command_exit
351
- # (lb): Commander's at_exit hook calls runner.run! which runs the
352
- # command that was determined with Commander was loaded. I tried a
353
- # few different ways to reset Runner.instance, but nothing worked;
354
- # our best bet is to just call the command directly.
355
- the_cmd = command(cmd.to_sym)
356
- raise "Specified command not recognized! “#{cmd}”" if the_cmd.nil?
357
- when_called = the_cmd.peek_when_called.dup
358
-
359
- runner.force_args(args.dup)
360
- #runner.parse_global_options
361
- if wont_parse
362
- expect { runner.old_parse_global_options }.to raise_error(SystemExit)
363
- else
364
- runner.old_parse_global_options
365
- runner.remove_global_options runner.options, args
366
- if wont_run == true
367
- expect { the_cmd.run(*args) }.to raise_error(SystemExit)
368
- else
369
- begin
370
- the_cmd.run(*args)
371
- rescue StandardError => _err
372
- # This is unexpected. Leave $exited_abnormally so we warn the user.
373
- restore_stdio
374
- raise
375
- rescue SystemExit => _err
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
393
- end
394
- end
395
- end
396
-
397
- # Reset proxy_options otherwise Commander::Command.call
398
- # uses them the next time this command is called.
399
- the_cmd.proxy_options = []
400
- the_cmd.when_called = when_called
401
- end
402
- runner.command_exit = nil
403
-
404
- $exited_abnormally = false
405
- # Ruby provides std i/o constants, so we could do this:
406
- # $stdout, $stderr = STDOUT, STDERR
407
- restore_stdio
408
-
409
- HighLine.use_color = true
410
- Rainbow.enabled = true
411
-
412
- [
413
- MrMurano::Progress.strip_color(tmpout.string),
414
- MrMurano::Progress.strip_color(tmperr.string),
415
- ]
416
- end
417
-
418
- def cmd_verify_help(cmd_name)
419
- stdout, stderr = murano_command_run(cmd_name)
420
- expect(stdout).to start_with(
421
- " NAME:\n\n murano #{cmd_name}\n\n DESCRIPTION:\n\n "
422
- )
423
- expect(stderr).to eq('')
424
- end
425
-
426
- # *** before() and around()
427
-
428
- before(:context) do
429
- @timeit_time0 = Time.now
430
- end
431
-
432
- after(:context) do
433
- elapsed_secs = Time.now - @timeit_time0
434
- puts "\n .. elapsed: #{elapsed_secs.round(2)} secs."
435
- end
436
-
437
- # Before: Load Config.
438
- before(:example) do |example|
439
- $cfg = MrMurano::Config.new
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
450
- end
451
-
452
- # Around: Make project dir under /tmp.
453
- around(:example) do |example|
454
- # Load the byebug library now, before changing directories.
455
- # This sets Setting[:histfile]. Within byebug, try `show histfile`.
456
- # Make sure this is set now, otherwise, byebug crashes, e.g.,
457
- # <Errno::ENOENT: No such file or directory @ rb_sysopen -
458
- # /tmp/d20170830-10087-h7tq6a/project/.byebug_history>
459
- # This happens if the first call to byebug is after the chdir.
460
- # Byebug creates the histfile in the tmp dir. So the next time
461
- # the method containing `byebug` is called, it's from within a
462
- # different tmp dir, and the old tmp dir has been removed. So
463
- # byebug crashes trying to access the old, missing histfile.
464
- require 'byebug/settings/histfile'
465
- _ignored = ::Byebug::HistfileSetting::DEFAULT
466
-
467
- $exited_abnormally = example.example.to_s
468
-
469
- @testdir = Pathname.new(Dir.pwd).realpath
470
- Dir.mktmpdir do |hdir|
471
- saved_home = Dir.home
472
- ENV['HOME'] = hdir
473
- Dir.chdir(hdir) do
474
- Dir.mkdir('.murano')
475
-
476
- Dir.chdir('.murano') do
477
- begin
478
- FileUtils.ln_s(File.join(saved_home, '.murano', 'tokens'), 'tokens')
479
- rescue NotImplementedError => err
480
- require 'rbconfig'
481
- unless OS.windows?
482
- warn(
483
- 'Unexpected: ln_s failed on non-Windows machine / ' \
484
- "host_os: #{RbConfig::CONFIG['host_os']} / err: #{err}"
485
- )
486
- end
487
- end
488
- end
489
-
490
- @tmpdir = File.join(hdir, 'project')
491
- Dir.mkdir(@tmpdir)
492
- Dir.chdir(@tmpdir) do
493
- mk_symlink
494
- # Timeout after 300 secs/5 mins.
495
- Timeout.timeout(300) do
496
- example.run
497
- end
498
- rm_symlink
499
- end
500
- end
501
- ENV['HOME'] = saved_home
502
- end
503
-
504
- $exited_abnormally = false
505
- end
506
- end
507
-