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
@@ -1,562 +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 'pathname'
9
- require 'tempfile'
10
- require 'MrMurano/version'
11
- require 'MrMurano/HttpAuthed'
12
- require 'MrMurano/ProjectFile'
13
- require 'MrMurano/Solution-Services'
14
- require '_workspace'
15
- require 'HttpAuthed_spec'
16
-
17
- RSpec.describe MrMurano::Module do
18
- include_context 'WORKSPACE'
19
- before(:example) do
20
- $cfg = MrMurano::Config.new
21
- $cfg.load
22
- $project = MrMurano::ProjectFile.new
23
- $project.load
24
- $cfg['net.host'] = 'bizapi.hosted.exosite.io'
25
- $cfg['application.id'] = 'XYZ'
26
- stub_request_email_password
27
-
28
- @srv = MrMurano::Module.new
29
- MrMurano::HttpAuthed.instance.instance_variable_set(:@token_biz, 'TTTTTTTTTT')
30
- end
31
-
32
- it 'initializes' do
33
- uri = @srv.endpoint('/')
34
- expect(uri.to_s).to eq(
35
- 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/'
36
- )
37
- end
38
-
39
- it 'lists' do
40
- body = {
41
- items: [
42
- {
43
- id: '9K0',
44
- name: 'debug',
45
- alias: 'XYZ_debug',
46
- solution_id: 'XYZ',
47
- created_at: '2016-07-07T19:16:19.479Z',
48
- updated_at: '2016-09-12T13:26:55.868Z',
49
- },
50
- ],
51
- total: 1,
52
- }
53
- stub_request(
54
- :get, 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module'
55
- ).with(
56
- headers: {
57
- 'Authorization' => 'token TTTTTTTTTT',
58
- 'Content-Type' => 'application/json',
59
- }
60
- ).to_return(body: body.to_json)
61
-
62
- ret = @srv.list
63
- expect(ret).to eq(body[:items])
64
- end
65
-
66
- context 'fetching' do
67
- it 'fetches' do
68
- body = {
69
- id: '9K0',
70
- name: 'debug',
71
- alias: 'XYZ_debug',
72
- solution_id: 'XYZ',
73
- created_at: '2016-07-07T19:16:19.479Z',
74
- updated_at: '2016-09-12T13:26:55.868Z',
75
- script: %{-- lua code is here
76
- function foo(bar)
77
- return bar + 1
78
- end
79
- },
80
- }
81
- stub_request(
82
- :get, 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/9K0'
83
- ).with(
84
- headers: {
85
- 'Authorization' => 'token TTTTTTTTTT',
86
- 'Content-Type' => 'application/json',
87
- }
88
- ).to_return(body: body.to_json)
89
-
90
- ret = @srv.fetch('9K0')
91
- expect(ret).to eq(body[:script])
92
- end
93
-
94
- it 'fetches with block' do
95
- body = {
96
- id: '9K0',
97
- name: 'debug',
98
- alias: 'XYZ_debug',
99
- solution_id: 'XYZ',
100
- created_at: '2016-07-07T19:16:19.479Z',
101
- updated_at: '2016-09-12T13:26:55.868Z',
102
- script: %{-- lua code is here
103
- function foo(bar)
104
- return bar + 1
105
- end
106
- },
107
- }
108
- stub_request(
109
- :get, 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/9K0'
110
- ).with(
111
- headers: {
112
- 'Authorization' => 'token TTTTTTTTTT',
113
- 'Content-Type' => 'application/json',
114
- }
115
- ).to_return(body: body.to_json)
116
-
117
- ret = nil
118
- @srv.fetch('9K0') { |sc| ret = sc }
119
- expect(ret).to eq(body[:script])
120
- end
121
-
122
- it 'Returns empty if script missing' do
123
- body = {
124
- id: '9K0',
125
- name: 'debug',
126
- alias: 'XYZ_debug',
127
- solution_id: 'XYZ',
128
- created_at: '2016-07-07T19:16:19.479Z',
129
- updated_at: '2016-09-12T13:26:55.868Z',
130
- }
131
- stub_request(
132
- :get, 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/9K0'
133
- ).with(
134
- headers: {
135
- 'Authorization' => 'token TTTTTTTTTT',
136
- 'Content-Type' => 'application/json',
137
- }
138
- ).to_return(body: body.to_json)
139
-
140
- ret = @srv.fetch('9K0')
141
- expect(ret).to eq('')
142
- end
143
-
144
- it 'Displays error if wrong result type' do
145
- stub_request(
146
- :get, 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/9K0'
147
- ).with(
148
- headers: {
149
- 'Authorization' => 'token TTTTTTTTTT',
150
- 'Content-Type' => 'application/json',
151
- }
152
- ).to_return(body: "this isn't what we expected")
153
-
154
- saved = $stderr
155
- $stderr = StringIO.new
156
- ret = @srv.fetch('9K0')
157
- expect(ret).to eq('')
158
- expect($stderr.string).to start_with(
159
- %(\e[31m#{MrMurano::SolutionId::UNEXPECTED_TYPE_OR_ERROR_MSG})
160
- )
161
- $stderr = saved
162
- end
163
- end
164
-
165
- it 'removes' do
166
- stub_request(
167
- :delete, 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/9K0'
168
- ).with(
169
- headers: {
170
- 'Authorization' => 'token TTTTTTTTTT',
171
- 'Content-Type' => 'application/json',
172
- }
173
- ).to_return(body: '')
174
-
175
- ret = @srv.remove('9K0')
176
- expect(ret).to eq({})
177
- end
178
-
179
- context 'uploads' do
180
- it 'over old version' do
181
- stub_request(
182
- :put, 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/XYZ_debug'
183
- ).with(
184
- headers: {
185
- 'Authorization' => 'token TTTTTTTTTT',
186
- 'Content-Type' => 'application/json',
187
- }
188
- ).to_return(body: '')
189
-
190
- Tempfile.open('foo') do |tio|
191
- tio << %{-- lua code is here
192
- function foo(bar)
193
- return bar + 1
194
- end
195
- }
196
- tio.close
197
-
198
- ret = @srv.upload(
199
- tio.path,
200
- MrMurano::Module::ModuleItem.new(
201
- id: '9K0',
202
- name: 'debug',
203
- alias: 'XYZ_debug',
204
- solution_id: 'XYZ',
205
- )
206
- )
207
- expect(ret)
208
- end
209
- end
210
-
211
- it 'when nothing is there' do
212
- stub_request(
213
- :put, 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/XYZ_debug'
214
- ).with(
215
- headers: {
216
- 'Authorization' => 'token TTTTTTTTTT',
217
- 'Content-Type' => 'application/json',
218
- }
219
- ).to_return(status: 404)
220
- stub_request(
221
- :post, 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/'
222
- ).with(
223
- headers: {
224
- 'Authorization' => 'token TTTTTTTTTT',
225
- 'Content-Type' => 'application/json',
226
- }
227
- ).to_return(body: '')
228
-
229
- Tempfile.open('foo') do |tio|
230
- tio << %{-- lua code is here
231
- function foo(bar)
232
- return bar + 1
233
- end
234
- }
235
- tio.close
236
-
237
- ret = @srv.upload(
238
- tio.path,
239
- MrMurano::Module::ModuleItem.new(
240
- id: '9K0',
241
- name: 'debug',
242
- alias: 'XYZ_debug',
243
- solution_id: 'XYZ',
244
- )
245
- )
246
- expect(ret)
247
- end
248
- end
249
-
250
- it 'shows other errors' do
251
- stub_request(
252
- :put, 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/XYZ_debug'
253
- ).with(
254
- headers: {
255
- 'Authorization' => 'token TTTTTTTTTT',
256
- 'Content-Type' => 'application/json',
257
- }
258
- ).to_return(status: 418, body: %({"teapot":true}))
259
-
260
- Tempfile.open('foo') do |tio|
261
- tio << %{-- lua code is here
262
- function foo(bar)
263
- return bar + 1
264
- end
265
- }
266
- tio.close
267
-
268
- expect(@srv).to receive(:error).and_return(nil)
269
- ret = @srv.upload(
270
- tio.path,
271
- MrMurano::Module::ModuleItem.new(
272
- id: '9K0',
273
- name: 'debug',
274
- alias: 'XYZ_debug',
275
- solution_id: 'XYZ',
276
- )
277
- )
278
- expect(ret)
279
- end
280
- end
281
-
282
- it 'over old version; replacing cache miss' do
283
- stub_request(
284
- :put, 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/XYZ_debug'
285
- ).with(
286
- headers: {
287
- 'Authorization' => 'token TTTTTTTTTT',
288
- 'Content-Type' => 'application/json',
289
- }
290
- ).to_return(body: '')
291
-
292
- Tempfile.open('foo') do |tio|
293
- tio << %{-- lua code is here
294
- function foo(bar)
295
- return bar + 1
296
- end
297
- }
298
- tio.close
299
-
300
- cache_file = $cfg.file_at(@srv.cache_file_name)
301
- FileUtils.touch(cache_file.to_path)
302
- ret = @srv.upload(
303
- tio.path,
304
- MrMurano::Module::ModuleItem.new(
305
- id: '9K0',
306
- name: 'debug',
307
- alias: 'XYZ_debug',
308
- solution_id: 'XYZ',
309
- )
310
- )
311
- expect(ret)
312
- end
313
- end
314
-
315
- it 'over old version; replacing cache hit' do
316
- stub_request(
317
- :put, 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/XYZ_debug'
318
- ).with(
319
- headers: {
320
- 'Authorization' => 'token TTTTTTTTTT',
321
- 'Content-Type' => 'application/json',
322
- }
323
- ).to_return(body: '')
324
-
325
- Tempfile.open('foo') do |tio|
326
- tio << %{-- lua code is here
327
- function foo(bar)
328
- return bar + 1
329
- end
330
- }
331
- tio.close
332
-
333
- cache_file = $cfg.file_at(@srv.cache_file_name)
334
- cache_file.open('w') do |cfio|
335
- cfio << {
336
- tio.path => {
337
- sha1: '6',
338
- updated_at: Time.now.getutc.to_datetime.iso8601(3),
339
- },
340
- }.to_yaml
341
- end
342
- ret = @srv.upload(
343
- tio.path,
344
- MrMurano::Module::ModuleItem.new(
345
- id: '9K0',
346
- name: 'debug',
347
- alias: 'XYZ_debug',
348
- solution_id: 'XYZ',
349
- )
350
- )
351
- expect(ret)
352
- end
353
- end
354
- end
355
-
356
- context 'compares' do
357
- before(:example) do
358
- @i_a = {
359
- id: '9K0',
360
- name: 'debug',
361
- alias: 'XYZ_debug',
362
- solution_id: 'XYZ',
363
- created_at: '2016-07-07T19:16:19.479Z',
364
- updated_at: '2016-09-12T13:26:55.868Z',
365
- }
366
- @i_b = {
367
- id: '9K0',
368
- name: 'debug',
369
- alias: 'XYZ_debug',
370
- solution_id: 'XYZ',
371
- created_at: '2016-07-07T19:16:19.479Z',
372
- updated_at: '2016-09-12T13:26:55.868Z',
373
- }
374
- end
375
- it 'both have updated_at' do
376
- ret = @srv.docmp(@i_a, @i_b)
377
- expect(ret).to eq(false)
378
- end
379
-
380
- context 'i_a is a local file' do
381
- it 'no cache_file' do
382
- Tempfile.open('foo') do |tio|
383
- tio << 'something'
384
- tio.close
385
- i_a = @i_a.reject do |k, _v|
386
- k == :updated_at
387
- end.merge(local_path: Pathname.new(tio.path))
388
- ret = @srv.docmp(i_a, @i_b)
389
- expect(ret).to eq(true)
390
-
391
- i_b = @i_b.merge(updated_at: Pathname.new(tio.path).mtime.getutc)
392
- ret = @srv.docmp(i_a, i_b)
393
- expect(ret).to eq(false)
394
- end
395
- end
396
-
397
- it 'cache miss' do
398
- cache_file = $cfg.file_at(@srv.cache_file_name)
399
- FileUtils.touch(cache_file.to_path)
400
- Tempfile.open('foo') do |tio|
401
- tio << 'something'
402
- tio.close
403
- i_a = @i_a.reject do |k, _v|
404
- k == :updated_at
405
- end.merge(local_path: Pathname.new(tio.path))
406
- ret = @srv.docmp(i_a, @i_b)
407
- expect(ret).to eq(true)
408
-
409
- i_b = @i_b.merge(updated_at: Pathname.new(tio.path).mtime.getutc)
410
- ret = @srv.docmp(i_a, i_b)
411
- expect(ret).to eq(false)
412
- end
413
- end
414
-
415
- it 'cache hit' do
416
- cache_file = $cfg.file_at(@srv.cache_file_name)
417
- Tempfile.open('foo') do |tio|
418
- tio << 'something'
419
- tio.close
420
- tio_mtime = Pathname.new(tio.path).mtime.getutc
421
- entry = {
422
- sha1: Digest::SHA1.file(tio.path).hexdigest,
423
- updated_at: tio_mtime.to_datetime.iso8601(3),
424
- }
425
- cache_file.open('w') do |io|
426
- cache = {}
427
- cache[tio.path] = entry
428
- io << cache.to_yaml
429
- end
430
-
431
- i_a = @i_a.reject do |k, _v|
432
- k == :updated_at
433
- end.merge(local_path: Pathname.new(tio.path))
434
- ret = @srv.docmp(i_a, @i_b)
435
- expect(ret).to eq(true)
436
-
437
- i_b = @i_b.merge(updated_at: tio_mtime)
438
- ret = @srv.docmp(i_a, i_b)
439
- expect(ret).to eq(false)
440
- end
441
- end
442
- end
443
-
444
- context 'i_b is a local file' do
445
- it 'no cache_file' do
446
- Tempfile.open('foo') do |tio|
447
- tio << 'something'
448
- tio.close
449
- i_b = @i_b.reject do |k, _v|
450
- k == :updated_at
451
- end.merge(local_path: Pathname.new(tio.path))
452
- ret = @srv.docmp(@i_a, i_b)
453
- expect(ret).to eq(true)
454
-
455
- i_a = @i_a.merge(updated_at: Pathname.new(tio.path).mtime.getutc)
456
- ret = @srv.docmp(i_a, i_b)
457
- expect(ret).to eq(false)
458
- end
459
- end
460
-
461
- it 'cache miss' do
462
- cache_file = $cfg.file_at(@srv.cache_file_name)
463
- FileUtils.touch(cache_file.to_path)
464
- Tempfile.open('foo') do |tio|
465
- tio << 'something'
466
- tio.close
467
- i_b = @i_b.reject do |k, _v|
468
- k == :updated_at
469
- end.merge(local_path: Pathname.new(tio.path))
470
- ret = @srv.docmp(@i_a, i_b)
471
- expect(ret).to eq(true)
472
-
473
- i_a = @i_a.merge(updated_at: Pathname.new(tio.path).mtime.getutc)
474
- ret = @srv.docmp(i_a, i_b)
475
- expect(ret).to eq(false)
476
- end
477
- end
478
-
479
- it 'cache hit' do
480
- cache_file = $cfg.file_at(@srv.cache_file_name)
481
- Tempfile.open('foo') do |tio|
482
- tio << 'something'
483
- tio.close
484
- tio_mtime = Pathname.new(tio.path).mtime.getutc
485
- entry = {
486
- sha1: Digest::SHA1.file(tio.path).hexdigest,
487
- updated_at: tio_mtime.to_datetime.iso8601(3),
488
- }
489
- cache_file.open('w') do |io|
490
- cache = {}
491
- cache[tio.path] = entry
492
- io << cache.to_yaml
493
- end
494
-
495
- i_b = @i_b.reject do |k, _v|
496
- k == :updated_at
497
- end.merge(local_path: Pathname.new(tio.path))
498
- ret = @srv.docmp(@i_a, i_b)
499
- expect(ret).to eq(true)
500
-
501
- i_a = @i_a.merge(updated_at: tio_mtime)
502
- ret = @srv.docmp(i_a, i_b)
503
- expect(ret).to eq(false)
504
- end
505
- end
506
- end
507
- end
508
-
509
- context 'Lookup functions' do
510
- it 'gets local name' do
511
- ret = @srv.tolocalname({ name: 'bob' }, nil)
512
- expect(ret).to eq('bob.lua')
513
- end
514
-
515
- it 'gets synckey' do
516
- ret = @srv.synckey(name: 'device')
517
- expect(ret).to eq('device')
518
- end
519
-
520
- it 'gets searchfor' do
521
- $cfg['modules.searchFor'] = %(a b c/**/d/*.bob)
522
- ret = @srv.searchFor
523
- expect(ret).to eq(['a', 'b', 'c/**/d/*.bob'])
524
- end
525
-
526
- it 'gets ignoring' do
527
- $cfg['modules.ignoring'] = %(a b c/**/d/*.bob)
528
- ret = @srv.ignoring
529
- expect(ret).to eq(['a', 'b', 'c/**/d/*.bob'])
530
- end
531
-
532
- it 'raises on alias without name' do
533
- expect do
534
- @srv.mkname(MrMurano::Module::EventHandlerItem.new)
535
- end.to raise_error(NameError)
536
- end
537
-
538
- it 'raises on name without name' do
539
- expect do
540
- @srv.mkalias(MrMurano::Module::EventHandlerItem.new)
541
- end.to raise_error(NameError)
542
- end
543
- end
544
-
545
- context 'to_remote_items' do
546
- it 'reads one' do
547
- root = Pathname.new(@project_dir)
548
- path = Pathname.new(@project_dir) + 'test.lua'
549
- want = [{ name: 'test' }]
550
- ret = @srv.to_remote_items(root, path)
551
- expect(ret).to eq(want)
552
- end
553
- it 'reads sub folder one' do
554
- root = Pathname.new(@project_dir)
555
- path = Pathname.new(@project_dir) + 'src/test.lua'
556
- ret = @srv.to_remote_items(root, path)
557
- want = [{ name: 'src.test' }]
558
- expect(ret).to eq(want)
559
- end
560
- end
561
- end
562
-