MuranoCLI 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +28 -0
- data/.rspec +2 -0
- data/.travis.yml +21 -0
- data/Gemfile +27 -0
- data/LICENSE.txt +19 -0
- data/MuranoCLI.gemspec +50 -0
- data/MuranoCLI.iss +50 -0
- data/README.markdown +208 -0
- data/Rakefile +188 -0
- data/TODO.taskpaper +122 -0
- data/bin/mr +8 -0
- data/bin/murano +84 -0
- data/docs/demo.md +109 -0
- data/lib/MrMurano/Account.rb +211 -0
- data/lib/MrMurano/Config-Migrate.rb +47 -0
- data/lib/MrMurano/Config.rb +286 -0
- data/lib/MrMurano/Mock.rb +63 -0
- data/lib/MrMurano/Product-1P-Device.rb +145 -0
- data/lib/MrMurano/Product-Resources.rb +195 -0
- data/lib/MrMurano/Product.rb +358 -0
- data/lib/MrMurano/ProjectFile.rb +349 -0
- data/lib/MrMurano/Solution-Cors.rb +46 -0
- data/lib/MrMurano/Solution-Endpoint.rb +177 -0
- data/lib/MrMurano/Solution-File.rb +150 -0
- data/lib/MrMurano/Solution-ServiceConfig.rb +140 -0
- data/lib/MrMurano/Solution-Services.rb +326 -0
- data/lib/MrMurano/Solution-Users.rb +129 -0
- data/lib/MrMurano/Solution.rb +59 -0
- data/lib/MrMurano/SubCmdGroupContext.rb +49 -0
- data/lib/MrMurano/SyncUpDown.rb +565 -0
- data/lib/MrMurano/commands/assign.rb +57 -0
- data/lib/MrMurano/commands/businessList.rb +45 -0
- data/lib/MrMurano/commands/completion.rb +152 -0
- data/lib/MrMurano/commands/config.rb +67 -0
- data/lib/MrMurano/commands/content.rb +130 -0
- data/lib/MrMurano/commands/cors.rb +30 -0
- data/lib/MrMurano/commands/domain.rb +17 -0
- data/lib/MrMurano/commands/gb.rb +33 -0
- data/lib/MrMurano/commands/init.rb +138 -0
- data/lib/MrMurano/commands/keystore.rb +157 -0
- data/lib/MrMurano/commands/logs.rb +78 -0
- data/lib/MrMurano/commands/mock.rb +63 -0
- data/lib/MrMurano/commands/password.rb +88 -0
- data/lib/MrMurano/commands/postgresql.rb +41 -0
- data/lib/MrMurano/commands/product.rb +14 -0
- data/lib/MrMurano/commands/productCreate.rb +39 -0
- data/lib/MrMurano/commands/productDelete.rb +33 -0
- data/lib/MrMurano/commands/productDevice.rb +84 -0
- data/lib/MrMurano/commands/productDeviceIdCmds.rb +86 -0
- data/lib/MrMurano/commands/productList.rb +45 -0
- data/lib/MrMurano/commands/productWrite.rb +27 -0
- data/lib/MrMurano/commands/show.rb +80 -0
- data/lib/MrMurano/commands/solution.rb +14 -0
- data/lib/MrMurano/commands/solutionCreate.rb +39 -0
- data/lib/MrMurano/commands/solutionDelete.rb +34 -0
- data/lib/MrMurano/commands/solutionList.rb +45 -0
- data/lib/MrMurano/commands/status.rb +92 -0
- data/lib/MrMurano/commands/sync.rb +60 -0
- data/lib/MrMurano/commands/timeseries.rb +115 -0
- data/lib/MrMurano/commands/tsdb.rb +271 -0
- data/lib/MrMurano/commands/usage.rb +23 -0
- data/lib/MrMurano/commands/zshcomplete.erb +112 -0
- data/lib/MrMurano/commands.rb +32 -0
- data/lib/MrMurano/hash.rb +20 -0
- data/lib/MrMurano/http.rb +153 -0
- data/lib/MrMurano/makePretty.rb +75 -0
- data/lib/MrMurano/schema/pf-v1.0.0.yaml +114 -0
- data/lib/MrMurano/schema/sf-v0.2.0.yaml +77 -0
- data/lib/MrMurano/schema/sf-v0.3.0.yaml +78 -0
- data/lib/MrMurano/template/mock.erb +9 -0
- data/lib/MrMurano/template/projectFile.murano.erb +81 -0
- data/lib/MrMurano/verbosing.rb +99 -0
- data/lib/MrMurano/version.rb +4 -0
- data/lib/MrMurano.rb +20 -0
- data/spec/Account-Passwords_spec.rb +242 -0
- data/spec/Account_spec.rb +272 -0
- data/spec/ConfigFile_spec.rb +50 -0
- data/spec/ConfigMigrate_spec.rb +89 -0
- data/spec/Config_spec.rb +409 -0
- data/spec/Http_spec.rb +204 -0
- data/spec/MakePretties_spec.rb +118 -0
- data/spec/Mock_spec.rb +53 -0
- data/spec/ProductBase_spec.rb +113 -0
- data/spec/ProductContent_spec.rb +162 -0
- data/spec/ProductResources_spec.rb +329 -0
- data/spec/Product_1P_Device_spec.rb +202 -0
- data/spec/Product_1P_RPC_spec.rb +175 -0
- data/spec/Product_spec.rb +153 -0
- data/spec/ProjectFile_spec.rb +324 -0
- data/spec/Solution-Cors_spec.rb +164 -0
- data/spec/Solution-Endpoint_spec.rb +581 -0
- data/spec/Solution-File_spec.rb +212 -0
- data/spec/Solution-ServiceConfig_spec.rb +202 -0
- data/spec/Solution-ServiceDevice_spec.rb +176 -0
- data/spec/Solution-ServiceEventHandler_spec.rb +385 -0
- data/spec/Solution-ServiceModules_spec.rb +465 -0
- data/spec/Solution-UsersRoles_spec.rb +207 -0
- data/spec/Solution_spec.rb +92 -0
- data/spec/SyncRoot_spec.rb +83 -0
- data/spec/SyncUpDown_spec.rb +495 -0
- data/spec/Verbosing_spec.rb +279 -0
- data/spec/_workspace.rb +27 -0
- data/spec/cmd_assign_spec.rb +51 -0
- data/spec/cmd_business_spec.rb +59 -0
- data/spec/cmd_common.rb +72 -0
- data/spec/cmd_config_spec.rb +68 -0
- data/spec/cmd_content_spec.rb +71 -0
- data/spec/cmd_cors_spec.rb +50 -0
- data/spec/cmd_device_spec.rb +96 -0
- data/spec/cmd_domain_spec.rb +32 -0
- data/spec/cmd_init_spec.rb +30 -0
- data/spec/cmd_keystore_spec.rb +97 -0
- data/spec/cmd_password_spec.rb +62 -0
- data/spec/cmd_status_spec.rb +239 -0
- data/spec/cmd_syncdown_spec.rb +86 -0
- data/spec/cmd_syncup_spec.rb +62 -0
- data/spec/cmd_usage_spec.rb +36 -0
- data/spec/fixtures/.mrmuranorc +9 -0
- data/spec/fixtures/ProjectFiles/invalid.yaml +9 -0
- data/spec/fixtures/ProjectFiles/only_meta.yaml +24 -0
- data/spec/fixtures/ProjectFiles/with_routes.yaml +27 -0
- data/spec/fixtures/SolutionFiles/0.2.0.json +20 -0
- data/spec/fixtures/SolutionFiles/0.2.0_invalid.json +18 -0
- data/spec/fixtures/SolutionFiles/0.2.json +21 -0
- data/spec/fixtures/SolutionFiles/0.3.0.json +20 -0
- data/spec/fixtures/SolutionFiles/0.3.0_invalid.json +19 -0
- data/spec/fixtures/SolutionFiles/0.3.json +20 -0
- data/spec/fixtures/SolutionFiles/basic.json +20 -0
- data/spec/fixtures/SolutionFiles/secret.json +6 -0
- data/spec/fixtures/configfile +9 -0
- data/spec/fixtures/dumped_config +42 -0
- data/spec/fixtures/mrmuranorc_deleted_bob +8 -0
- data/spec/fixtures/mrmuranorc_tool_bob +3 -0
- data/spec/fixtures/product_spec_files/example.exoline.spec.yaml +116 -0
- data/spec/fixtures/product_spec_files/example.murano.spec.yaml +14 -0
- data/spec/fixtures/product_spec_files/gwe.exoline.spec.yaml +21 -0
- data/spec/fixtures/product_spec_files/gwe.murano.spec.yaml +16 -0
- data/spec/fixtures/product_spec_files/lightbulb-no-state.yaml +11 -0
- data/spec/fixtures/product_spec_files/lightbulb.yaml +14 -0
- data/spec/fixtures/roles-three.yaml +11 -0
- data/spec/fixtures/syncable_content/assets/icon.png +0 -0
- data/spec/fixtures/syncable_content/assets/index.html +0 -0
- data/spec/fixtures/syncable_content/assets/js/script.js +0 -0
- data/spec/fixtures/syncable_content/modules/table_util.lua +58 -0
- data/spec/fixtures/syncable_content/routes/manyRoutes.lua +11 -0
- data/spec/fixtures/syncable_content/routes/singleRoute.lua +5 -0
- data/spec/fixtures/syncable_content/services/devdata.lua +18 -0
- data/spec/fixtures/syncable_content/services/timers.lua +4 -0
- data/spec/spec_helper.rb +119 -0
- metadata +498 -0
@@ -0,0 +1,279 @@
|
|
1
|
+
require 'highline/import'
|
2
|
+
require 'MrMurano/version'
|
3
|
+
require 'MrMurano/hash'
|
4
|
+
require 'MrMurano/verbosing'
|
5
|
+
require 'MrMurano/Config'
|
6
|
+
require '_workspace'
|
7
|
+
|
8
|
+
class VTst
|
9
|
+
include MrMurano::Verbose
|
10
|
+
def initialize
|
11
|
+
@token = nil
|
12
|
+
end
|
13
|
+
end
|
14
|
+
RSpec.describe MrMurano::Verbose do
|
15
|
+
include_context "WORKSPACE"
|
16
|
+
|
17
|
+
before(:example) do
|
18
|
+
$cfg = MrMurano::Config.new
|
19
|
+
$cfg.load
|
20
|
+
@tst = VTst.new
|
21
|
+
end
|
22
|
+
|
23
|
+
it "verboses" do
|
24
|
+
$cfg['tool.verbose'] = true
|
25
|
+
expect($terminal).to receive(:say).with('hello').once
|
26
|
+
@tst.verbose "hello"
|
27
|
+
end
|
28
|
+
|
29
|
+
it "is quiet" do
|
30
|
+
expect($terminal).to_not receive(:say)
|
31
|
+
@tst.verbose "hello"
|
32
|
+
end
|
33
|
+
|
34
|
+
it "debugs" do
|
35
|
+
$cfg['tool.debug'] = true
|
36
|
+
expect($terminal).to receive(:say).with('hello').once
|
37
|
+
@tst.debug "hello"
|
38
|
+
end
|
39
|
+
|
40
|
+
it "warns" do
|
41
|
+
expect($stderr).to receive(:puts).with("\e[33mhello\e[0m").once
|
42
|
+
@tst.warning "hello"
|
43
|
+
end
|
44
|
+
|
45
|
+
it "errors" do
|
46
|
+
expect($stderr).to receive(:puts).with("\e[31mhello\e[0m").once
|
47
|
+
@tst.error "hello"
|
48
|
+
end
|
49
|
+
|
50
|
+
context "tabularize" do
|
51
|
+
context "generating CSV" do
|
52
|
+
before(:example) do
|
53
|
+
$cfg['tool.outformat'] = 'csv'
|
54
|
+
end
|
55
|
+
|
56
|
+
it "takes Array" do
|
57
|
+
$stdout = StringIO.new
|
58
|
+
|
59
|
+
@tst.tabularize([[1,2,3,4,5,6,7],[10,20,30,40,50,60,70]])
|
60
|
+
|
61
|
+
expect($stdout.string).to eq("1,2,3,4,5,6,7\n10,20,30,40,50,60,70\n")
|
62
|
+
end
|
63
|
+
|
64
|
+
it "ducks to_a" do
|
65
|
+
$stdout = StringIO.new
|
66
|
+
|
67
|
+
class DuckToATest
|
68
|
+
def to_a
|
69
|
+
[[12],[13]]
|
70
|
+
end
|
71
|
+
end
|
72
|
+
@tst.tabularize(DuckToATest.new)
|
73
|
+
|
74
|
+
expect($stdout.string).to eq("12\n13\n")
|
75
|
+
end
|
76
|
+
|
77
|
+
it "ducks each" do
|
78
|
+
$stdout = StringIO.new
|
79
|
+
|
80
|
+
class DuckEachTest
|
81
|
+
def each(&block)
|
82
|
+
yield [22]
|
83
|
+
yield [44]
|
84
|
+
end
|
85
|
+
end
|
86
|
+
@tst.tabularize(DuckEachTest.new)
|
87
|
+
|
88
|
+
expect($stdout.string).to eq("22\n44\n")
|
89
|
+
end
|
90
|
+
|
91
|
+
context "takes Hash" do
|
92
|
+
before(:example) do
|
93
|
+
@hsh = {
|
94
|
+
:headers => [:one, :two, :three],
|
95
|
+
:title => "Test output",
|
96
|
+
:rows => [[1,2,3], [10,20,30]]
|
97
|
+
}
|
98
|
+
$stdout = StringIO.new
|
99
|
+
end
|
100
|
+
it "has all" do
|
101
|
+
@tst.tabularize(@hsh)
|
102
|
+
expect($stdout.string).to eq("one,two,three\n1,2,3\n10,20,30\n")
|
103
|
+
end
|
104
|
+
|
105
|
+
it "is empty" do
|
106
|
+
@tst.tabularize({})
|
107
|
+
expect($stdout.string).to eq("\n")
|
108
|
+
end
|
109
|
+
|
110
|
+
it "no headers" do
|
111
|
+
@hsh.delete :headers
|
112
|
+
@tst.tabularize(@hsh)
|
113
|
+
expect($stdout.string).to eq("1,2,3\n10,20,30\n")
|
114
|
+
end
|
115
|
+
|
116
|
+
it "no title" do
|
117
|
+
@hsh.delete :title
|
118
|
+
@tst.tabularize(@hsh)
|
119
|
+
expect($stdout.string).to eq("one,two,three\n1,2,3\n10,20,30\n")
|
120
|
+
end
|
121
|
+
|
122
|
+
it "no rows" do
|
123
|
+
@hsh.delete :rows
|
124
|
+
@tst.tabularize(@hsh)
|
125
|
+
expect($stdout.string).to eq("one,two,three\n\n")
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
it "errors if it can't" do
|
130
|
+
$stdout = StringIO.new
|
131
|
+
expect(@tst).to receive(:error).with("Don't know how to tabularize data.").once
|
132
|
+
@tst.tabularize(12)
|
133
|
+
end
|
134
|
+
|
135
|
+
it "takes Array, to custom stream" do
|
136
|
+
$stdout = StringIO.new
|
137
|
+
outer = StringIO.new
|
138
|
+
|
139
|
+
@tst.tabularize([[1,2,3,4,5,6,7],[10,20,30,40,50,60,70]], outer)
|
140
|
+
|
141
|
+
expect(outer.string).to eq("1,2,3,4,5,6,7\n10,20,30,40,50,60,70\n")
|
142
|
+
expect($stdout.string).to eq('')
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
context "generating a table" do
|
147
|
+
it "takes Array" do
|
148
|
+
$stdout = StringIO.new
|
149
|
+
@tst.tabularize([[1,2,3,4,5,6,7],[10,20,30,40,50,60,70]])
|
150
|
+
expect($stdout.string).to eq(
|
151
|
+
%{+----+----+----+----+----+----+----+
|
152
|
+
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
|
153
|
+
| 10 | 20 | 30 | 40 | 50 | 60 | 70 |
|
154
|
+
+----+----+----+----+----+----+----+
|
155
|
+
}.gsub(/^\s+/,'')
|
156
|
+
)
|
157
|
+
end
|
158
|
+
|
159
|
+
context "takes Hash" do
|
160
|
+
before(:example) do
|
161
|
+
@hsh = {
|
162
|
+
:headers => [:one, :two, :three],
|
163
|
+
:title => "Test output",
|
164
|
+
:rows => [[1,2,3], [10,20,30]]
|
165
|
+
}
|
166
|
+
$stdout = StringIO.new
|
167
|
+
end
|
168
|
+
it "has all" do
|
169
|
+
@tst.tabularize(@hsh)
|
170
|
+
expect($stdout.string).to eq(
|
171
|
+
%{+-----+-----+-------+
|
172
|
+
| Test output |
|
173
|
+
+-----+-----+-------+
|
174
|
+
| one | two | three |
|
175
|
+
+-----+-----+-------+
|
176
|
+
| 1 | 2 | 3 |
|
177
|
+
| 10 | 20 | 30 |
|
178
|
+
+-----+-----+-------+
|
179
|
+
}.gsub(/^\s+/,'')
|
180
|
+
)
|
181
|
+
end
|
182
|
+
|
183
|
+
it "is empty" do
|
184
|
+
@tst.tabularize({})
|
185
|
+
expect($stdout.string).to eq("++\n++\n")
|
186
|
+
end
|
187
|
+
|
188
|
+
it "no headers" do
|
189
|
+
@hsh.delete :headers
|
190
|
+
@tst.tabularize(@hsh)
|
191
|
+
expect($stdout.string).to eq(
|
192
|
+
%{+----+----+----+
|
193
|
+
| Test output |
|
194
|
+
+----+----+----+
|
195
|
+
| 1 | 2 | 3 |
|
196
|
+
| 10 | 20 | 30 |
|
197
|
+
+----+----+----+
|
198
|
+
}.gsub(/^\s+/,'')
|
199
|
+
)
|
200
|
+
end
|
201
|
+
|
202
|
+
it "no title" do
|
203
|
+
@hsh.delete :title
|
204
|
+
@tst.tabularize(@hsh)
|
205
|
+
expect($stdout.string).to eq(
|
206
|
+
%{+-----+-----+-------+
|
207
|
+
| one | two | three |
|
208
|
+
+-----+-----+-------+
|
209
|
+
| 1 | 2 | 3 |
|
210
|
+
| 10 | 20 | 30 |
|
211
|
+
+-----+-----+-------+
|
212
|
+
}.gsub(/^\s+/,'')
|
213
|
+
)
|
214
|
+
end
|
215
|
+
|
216
|
+
it "no rows" do
|
217
|
+
@hsh.delete :rows
|
218
|
+
@tst.tabularize(@hsh)
|
219
|
+
expect($stdout.string).to eq(
|
220
|
+
%{+-----+-----+-------+
|
221
|
+
| Test output |
|
222
|
+
+-----+-----+-------+
|
223
|
+
| one | two | three |
|
224
|
+
+-----+-----+-------+
|
225
|
+
+-----+-----+-------+
|
226
|
+
}
|
227
|
+
)
|
228
|
+
end
|
229
|
+
end
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
context "outf" do
|
234
|
+
before(:example) do
|
235
|
+
@data = {
|
236
|
+
:one => "three",
|
237
|
+
:two => [ { :one => 3 }, { :one => 4} ]
|
238
|
+
}
|
239
|
+
$stdout = StringIO.new
|
240
|
+
end
|
241
|
+
|
242
|
+
it "outputs yaml" do
|
243
|
+
$cfg['tool.outformat'] = 'yaml'
|
244
|
+
@tst.outf(@data)
|
245
|
+
expect($stdout.string).to eq("---\none: three\ntwo:\n- one: 3\n- one: 4\n")
|
246
|
+
end
|
247
|
+
|
248
|
+
it "outputs json" do
|
249
|
+
$cfg['tool.outformat'] = 'json'
|
250
|
+
@tst.outf(@data)
|
251
|
+
expect($stdout.string).to eq("{\"one\":\"three\",\"two\":[{\"one\":3},{\"one\":4}]}\n")
|
252
|
+
end
|
253
|
+
|
254
|
+
it "outputs ruby" do
|
255
|
+
$cfg['tool.outformat'] = 'pp'
|
256
|
+
@tst.outf(@data)
|
257
|
+
expect($stdout.string).to eq("{:one=>\"three\", :two=>[{:one=>3}, {:one=>4}]}\n")
|
258
|
+
end
|
259
|
+
|
260
|
+
it "outputs as String" do
|
261
|
+
@tst.outf(@data)
|
262
|
+
expect($stdout.string).to eq("{:one=>\"three\", :two=>[{:one=>3}, {:one=>4}]}\n")
|
263
|
+
end
|
264
|
+
|
265
|
+
it "outputs as Array" do
|
266
|
+
@tst.outf([1,2,3,4,5])
|
267
|
+
expect($stdout.string).to eq("1\n2\n3\n4\n5\n")
|
268
|
+
end
|
269
|
+
|
270
|
+
it "returns to block" do
|
271
|
+
@tst.outf(@data) do |dd, ios|
|
272
|
+
ios.puts "pop"
|
273
|
+
end
|
274
|
+
expect($stdout.string).to eq("pop\n")
|
275
|
+
end
|
276
|
+
end
|
277
|
+
|
278
|
+
end
|
279
|
+
# vim: set ai et sw=2 ts=2 :
|
data/spec/_workspace.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'tmpdir'
|
4
|
+
|
5
|
+
RSpec.shared_context "WORKSPACE" do
|
6
|
+
|
7
|
+
around(:example) do |ex|
|
8
|
+
@testdir = Pathname.new(Dir.pwd).realpath
|
9
|
+
Dir.mktmpdir do |hdir|
|
10
|
+
@tmpdir = hdir
|
11
|
+
saved_home = ENV['HOME']
|
12
|
+
# Set ENV to override output of Dir.home
|
13
|
+
ENV['HOME'] = File.join(hdir, 'home')
|
14
|
+
FileUtils.mkpath(ENV['HOME'])
|
15
|
+
Dir.chdir(hdir) do
|
16
|
+
@projectDir = File.join(ENV['HOME'], 'work', 'project')
|
17
|
+
FileUtils.mkpath(@projectDir)
|
18
|
+
Dir.chdir(@projectDir) do
|
19
|
+
ex.run
|
20
|
+
end
|
21
|
+
end
|
22
|
+
ENV['HOME'] = saved_home
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# vim: set ai et sw=2 ts=2 :
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'open3'
|
3
|
+
require 'pathname'
|
4
|
+
require 'cmd_common'
|
5
|
+
|
6
|
+
RSpec.describe 'murano assign', :cmd, :needs_password do
|
7
|
+
include_context "CI_CMD"
|
8
|
+
|
9
|
+
before(:example) do
|
10
|
+
@project_name = rname('assigntest')
|
11
|
+
out, err, status = Open3.capture3(capcmd('murano', 'solution', 'create', @project_name, '--save'))
|
12
|
+
expect(err).to eq('')
|
13
|
+
expect(out.chomp).to match(/^[a-zA-Z0-9]+$/)
|
14
|
+
expect(status.exitstatus).to eq(0)
|
15
|
+
|
16
|
+
out, err, status = Open3.capture3(capcmd('murano', 'product', 'create', @project_name, '--save'))
|
17
|
+
expect(err).to eq('')
|
18
|
+
expect(out.chomp).to match(/^[a-zA-Z0-9]+$/)
|
19
|
+
expect(status.exitstatus).to eq(0)
|
20
|
+
end
|
21
|
+
after(:example) do
|
22
|
+
out, err, status = Open3.capture3(capcmd('murano', 'solution', 'delete', @project_name))
|
23
|
+
expect(out).to eq('')
|
24
|
+
expect(err).to eq('')
|
25
|
+
expect(status.exitstatus).to eq(0)
|
26
|
+
|
27
|
+
out, err, status = Open3.capture3(capcmd('murano', 'product', 'delete', @project_name))
|
28
|
+
expect(out).to eq('')
|
29
|
+
expect(err).to eq('')
|
30
|
+
expect(status.exitstatus).to eq(0)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "status" do
|
34
|
+
out, err, status = Open3.capture3(capcmd('murano', 'assign', 'set'))
|
35
|
+
expect(out).to eq('')
|
36
|
+
expect(err).to eq('')
|
37
|
+
expect(status.exitstatus).to eq(0)
|
38
|
+
|
39
|
+
out, err, status = Open3.capture3(capcmd('murano', 'assign', 'list'))
|
40
|
+
expect(err).to eq('')
|
41
|
+
olines = out.lines
|
42
|
+
expect(olines[0]).to match(/^(\+-+){2}\+$/)
|
43
|
+
expect(olines[1]).to match(/^\| Label\s+\| ModelID\s+\|$/)
|
44
|
+
expect(olines[2]).to match(/^(\+-+){2}\+$/)
|
45
|
+
expect(olines[-1]).to match(/^(\+-+){2}\+$/)
|
46
|
+
expect(status.exitstatus).to eq(0)
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
# vim: set ai et sw=2 ts=2 :
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'open3'
|
3
|
+
require 'pathname'
|
4
|
+
require 'cmd_common'
|
5
|
+
|
6
|
+
RSpec.describe 'murano business', :cmd, :needs_password do
|
7
|
+
include_context "CI_CMD"
|
8
|
+
|
9
|
+
context "list" do
|
10
|
+
it "as table" do
|
11
|
+
out, err, status = Open3.capture3(capcmd('murano', 'business', 'list'))
|
12
|
+
expect(err).to eq("")
|
13
|
+
olines = out.lines
|
14
|
+
expect(olines[0]).to match(/^(\+-+){3}\+$/)
|
15
|
+
expect(olines[1]).to match(/^\| bizid\s+\| role\s+\| name\s+\|$/)
|
16
|
+
expect(olines[2]).to match(/^(\+-+){3}\+$/)
|
17
|
+
expect(olines[-1]).to match(/^(\+-+){3}\+$/)
|
18
|
+
expect(status.exitstatus).to eq(0)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "as json" do
|
22
|
+
out, err, status = Open3.capture3(capcmd('murano', 'business', 'list', '-c', 'outformat=json'))
|
23
|
+
expect(err).to eq("")
|
24
|
+
expect{JSON.parse(out)}.to_not raise_error
|
25
|
+
expect(status.exitstatus).to eq(0)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "only ids" do
|
29
|
+
out, err, status = Open3.capture3(capcmd('murano', 'business', 'list', '--idonly'))
|
30
|
+
expect(err).to eq("")
|
31
|
+
expect(out).to match(/^(\S+\s)*\S+$/)
|
32
|
+
expect(status.exitstatus).to eq(0)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "output to file" do
|
36
|
+
out, err, status = Open3.capture3(capcmd('murano', 'business', 'list', '--idonly', '-o', 'bob'))
|
37
|
+
expect(err).to eq("")
|
38
|
+
expect(out).to eq('')
|
39
|
+
expect(status.exitstatus).to eq(0)
|
40
|
+
expect(File.exist?('bob')).to be true
|
41
|
+
data = IO.read('bob')
|
42
|
+
expect(data).to match(/^(\S+\s)*\S+$/)
|
43
|
+
end
|
44
|
+
|
45
|
+
it "all fields" do
|
46
|
+
out, err, status = Open3.capture3(capcmd('murano', 'business', 'list', '--all'))
|
47
|
+
expect(err).to eq("")
|
48
|
+
olines = out.lines
|
49
|
+
expect(olines[0]).to match(/^(\+-+)+\+$/)
|
50
|
+
expect(olines[1]).to match(/^(\| \S+\s+)+\|$/)
|
51
|
+
expect(olines[2]).to match(/^(\+-+)+\+$/)
|
52
|
+
expect(olines[-1]).to match(/^(\+-+)+\+$/)
|
53
|
+
expect(status.exitstatus).to eq(0)
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# vim: set ai et sw=2 ts=2 :
|
data/spec/cmd_common.rb
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require 'shellwords'
|
3
|
+
require 'timeout'
|
4
|
+
require 'tmpdir'
|
5
|
+
|
6
|
+
RSpec.shared_context "CI_CMD" do
|
7
|
+
def capcmd(*args)
|
8
|
+
args = [args] unless args.kind_of? Array
|
9
|
+
args.flatten!
|
10
|
+
testdir = File.realpath(@testdir.to_s)
|
11
|
+
if ENV['CI_MR_EXE'].nil? then
|
12
|
+
args[0] = File.join(testdir, 'bin', args[0])
|
13
|
+
args.unshift("ruby", "-I#{File.join(testdir, 'lib')}")
|
14
|
+
else
|
15
|
+
args[0] = File.join(testdir, (args[0] + '.exe'))
|
16
|
+
end
|
17
|
+
args.push '--trace'
|
18
|
+
args.push '-c', 'fullerror'
|
19
|
+
|
20
|
+
if Gem.win_platform? then
|
21
|
+
cmd = args.map do |i|
|
22
|
+
case i
|
23
|
+
when /[ ]/
|
24
|
+
%{"#{i}"}
|
25
|
+
when /[\*#]/
|
26
|
+
i.gsub(/([\*#])/,'^\1')
|
27
|
+
else
|
28
|
+
i
|
29
|
+
end
|
30
|
+
end.join(' ')
|
31
|
+
else
|
32
|
+
cmd = Shellwords.join(args)
|
33
|
+
end
|
34
|
+
#pp cmd
|
35
|
+
cmd
|
36
|
+
end
|
37
|
+
|
38
|
+
def rname(name)
|
39
|
+
"#{name}-#{Random.new.rand.hash.abs.to_s(16)}"
|
40
|
+
end
|
41
|
+
|
42
|
+
around(:example) do |ex|
|
43
|
+
@testdir = Pathname.new(Dir.pwd).realpath
|
44
|
+
Dir.mktmpdir do |hdir|
|
45
|
+
ENV['HOME'] = hdir
|
46
|
+
Dir.chdir(hdir) do
|
47
|
+
Dir.mkdir('.murano')
|
48
|
+
unless ENV['MURANO_USER'].nil? then
|
49
|
+
File.open(File.join('.murano', 'config'), 'a') do |io|
|
50
|
+
io << "[user]\n"
|
51
|
+
io << "name = #{ENV['MURANO_USER']}\n"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
unless ENV['MURANO_BUSINESS'].nil? then
|
55
|
+
File.open(File.join('.murano', 'config'), 'a') do |io|
|
56
|
+
io << "[business]\n"
|
57
|
+
io << "id = #{ENV['MURANO_BUSINESS']}\n"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
@tmpdir = File.join(hdir, 'project')
|
61
|
+
Dir.mkdir(@tmpdir)
|
62
|
+
Dir.chdir(@tmpdir) do
|
63
|
+
Timeout::timeout(300) do
|
64
|
+
ex.run
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
# vim: set ai et sw=2 ts=2 :
|