MuranoCLI 2.2.4 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.agignore +3 -0
- data/.gitignore +18 -1
- data/.rubocop.yml +222 -0
- data/.trustme.sh +185 -0
- data/.trustme.vim +24 -0
- data/Gemfile +23 -4
- data/LICENSE.txt +1 -1
- data/MuranoCLI.gemspec +43 -8
- data/README.markdown +9 -11
- data/Rakefile +187 -143
- data/TODO.taskpaper +2 -2
- data/bin/murano +51 -52
- data/docs/basic_example.rst +436 -0
- data/docs/completions/murano_completion-bash +3484 -0
- data/docs/demo.md +32 -32
- data/docs/develop.rst +391 -0
- data/lib/MrMurano.rb +21 -7
- data/lib/MrMurano/Account.rb +159 -174
- data/lib/MrMurano/Business.rb +381 -0
- data/lib/MrMurano/Config-Migrate.rb +32 -26
- data/lib/MrMurano/Config.rb +407 -128
- data/lib/MrMurano/Content.rb +191 -0
- data/lib/MrMurano/Gateway.rb +489 -0
- data/lib/MrMurano/Keystore.rb +48 -0
- data/lib/MrMurano/Passwords.rb +103 -0
- data/lib/MrMurano/ProjectFile.rb +121 -79
- data/lib/MrMurano/ReCommander.rb +114 -10
- data/lib/MrMurano/Setting.rb +90 -0
- data/lib/MrMurano/Solution-ServiceConfig.rb +89 -45
- data/lib/MrMurano/Solution-Services.rb +461 -166
- data/lib/MrMurano/Solution-Users.rb +70 -31
- data/lib/MrMurano/Solution.rb +372 -13
- data/lib/MrMurano/SolutionId.rb +73 -0
- data/lib/MrMurano/SyncRoot.rb +137 -0
- data/lib/MrMurano/SyncUpDown.rb +594 -284
- data/lib/MrMurano/Webservice-Cors.rb +71 -0
- data/lib/MrMurano/Webservice-Endpoint.rb +234 -0
- data/lib/MrMurano/Webservice-File.rb +193 -0
- data/lib/MrMurano/Webservice.rb +51 -0
- data/lib/MrMurano/commands.rb +18 -15
- data/lib/MrMurano/commands/business.rb +300 -6
- data/lib/MrMurano/commands/completion-bash.erb +166 -0
- data/lib/MrMurano/commands/{zshcomplete.erb → completion-zsh.erb} +0 -0
- data/lib/MrMurano/commands/completion.rb +76 -39
- data/lib/MrMurano/commands/config.rb +108 -44
- data/lib/MrMurano/commands/content.rb +115 -72
- data/lib/MrMurano/commands/cors.rb +29 -14
- data/lib/MrMurano/commands/devices.rb +286 -0
- data/lib/MrMurano/commands/domain.rb +52 -12
- data/lib/MrMurano/commands/gb.rb +24 -9
- data/lib/MrMurano/commands/globals.rb +64 -0
- data/lib/MrMurano/commands/init.rb +377 -155
- data/lib/MrMurano/commands/keystore.rb +92 -82
- data/lib/MrMurano/commands/link.rb +300 -0
- data/lib/MrMurano/commands/login.rb +74 -11
- data/lib/MrMurano/commands/logs.rb +63 -32
- data/lib/MrMurano/commands/mock.rb +57 -29
- data/lib/MrMurano/commands/password.rb +57 -39
- data/lib/MrMurano/commands/postgresql.rb +127 -94
- data/lib/MrMurano/commands/settings.rb +203 -0
- data/lib/MrMurano/commands/show.rb +79 -38
- data/lib/MrMurano/commands/solution.rb +423 -5
- data/lib/MrMurano/commands/solution_picker.rb +547 -0
- data/lib/MrMurano/commands/status.rb +195 -61
- data/lib/MrMurano/commands/sync.rb +78 -39
- data/lib/MrMurano/commands/timeseries.rb +71 -55
- data/lib/MrMurano/commands/tsdb.rb +113 -87
- data/lib/MrMurano/commands/usage.rb +57 -15
- data/lib/MrMurano/hash.rb +100 -10
- data/lib/MrMurano/http.rb +187 -43
- data/lib/MrMurano/makePretty.rb +16 -14
- data/lib/MrMurano/optparse.rb +2178 -0
- data/lib/MrMurano/progress.rb +138 -0
- data/lib/MrMurano/schema/resource-v1.0.0.yaml +32 -0
- data/lib/MrMurano/template/projectFile.murano.erb +16 -13
- data/lib/MrMurano/verbosing.rb +166 -29
- data/lib/MrMurano/version.rb +30 -1
- data/spec/Account-Passwords_spec.rb +21 -4
- data/spec/Account_spec.rb +69 -146
- data/spec/Business_spec.rb +290 -0
- data/spec/ConfigFile_spec.rb +1 -0
- data/spec/ConfigMigrate_spec.rb +12 -8
- data/spec/Config_spec.rb +40 -34
- data/spec/Content_spec.rb +363 -0
- data/spec/GatewayBase_spec.rb +54 -0
- data/spec/GatewayDevice_spec.rb +321 -0
- data/spec/GatewayResource_spec.rb +266 -0
- data/spec/GatewaySettings_spec.rb +120 -0
- data/spec/Http_spec.rb +18 -8
- data/spec/Mock_spec.rb +2 -2
- data/spec/ProjectFile_spec.rb +25 -14
- data/spec/Setting_spec.rb +110 -0
- data/spec/Solution-ServiceConfig_spec.rb +44 -5
- data/spec/Solution-ServiceEventHandler_spec.rb +23 -14
- data/spec/Solution-ServiceModules_spec.rb +47 -37
- data/spec/Solution-UsersRoles_spec.rb +10 -8
- data/spec/Solution_spec.rb +17 -8
- data/spec/SyncRoot_spec.rb +46 -20
- data/spec/SyncUpDown_spec.rb +437 -201
- data/spec/Verbosing_spec.rb +12 -4
- data/spec/{Solution-Cors_spec.rb → Webservice-Cors_spec.rb} +23 -20
- data/spec/{Solution-Endpoint_spec.rb → Webservice-Endpoint_spec.rb} +43 -41
- data/spec/{Solution-File_spec.rb → Webservice-File_spec.rb} +44 -33
- data/spec/Webservice-Setting_spec.rb +89 -0
- data/spec/_workspace.rb +4 -4
- data/spec/cmd_business_spec.rb +9 -4
- data/spec/cmd_common.rb +44 -1
- data/spec/cmd_content_spec.rb +43 -17
- data/spec/cmd_cors_spec.rb +4 -4
- data/spec/cmd_device_spec.rb +61 -16
- data/spec/cmd_domain_spec.rb +29 -6
- data/spec/cmd_init_spec.rb +281 -126
- data/spec/cmd_keystore_spec.rb +3 -3
- data/spec/cmd_link_spec.rb +98 -0
- data/spec/cmd_password_spec.rb +1 -1
- data/spec/cmd_setting_application_spec.rb +260 -0
- data/spec/cmd_setting_product_spec.rb +220 -0
- data/spec/cmd_status_spec.rb +223 -114
- data/spec/cmd_syncdown_spec.rb +115 -35
- data/spec/cmd_syncup_spec.rb +68 -15
- data/spec/cmd_usage_spec.rb +35 -8
- data/spec/fixtures/dumped_config +6 -4
- data/spec/fixtures/gateway_resource_files/resources.notyaml +12 -0
- data/spec/fixtures/gateway_resource_files/resources.yaml +13 -0
- data/spec/fixtures/gateway_resource_files/resources_invalid.yaml +13 -0
- data/spec/fixtures/mrmuranorc_deleted_bob +0 -2
- data/spec/fixtures/product_spec_files/lightbulb.yaml +20 -13
- data/spec/fixtures/{syncable_content → syncable_conflict}/services/devdata.lua +1 -1
- data/spec/fixtures/{syncable_content → syncable_conflict}/services/timers.lua +0 -0
- data/spec/spec_helper.rb +5 -0
- metadata +262 -171
- data/bin/mr +0 -8
- data/lib/MrMurano/Product-1P-Device.rb +0 -145
- data/lib/MrMurano/Product-Resources.rb +0 -205
- data/lib/MrMurano/Product.rb +0 -358
- data/lib/MrMurano/Solution-Cors.rb +0 -47
- data/lib/MrMurano/Solution-Endpoint.rb +0 -191
- data/lib/MrMurano/Solution-File.rb +0 -166
- data/lib/MrMurano/commands/assign.rb +0 -57
- data/lib/MrMurano/commands/businessList.rb +0 -45
- data/lib/MrMurano/commands/product.rb +0 -14
- data/lib/MrMurano/commands/productCreate.rb +0 -39
- data/lib/MrMurano/commands/productDelete.rb +0 -33
- data/lib/MrMurano/commands/productDevice.rb +0 -87
- data/lib/MrMurano/commands/productDeviceIdCmds.rb +0 -89
- data/lib/MrMurano/commands/productList.rb +0 -45
- data/lib/MrMurano/commands/productWrite.rb +0 -27
- data/lib/MrMurano/commands/solutionCreate.rb +0 -41
- data/lib/MrMurano/commands/solutionDelete.rb +0 -34
- data/lib/MrMurano/commands/solutionList.rb +0 -45
- data/spec/ProductBase_spec.rb +0 -113
- data/spec/ProductContent_spec.rb +0 -162
- data/spec/ProductResources_spec.rb +0 -329
- data/spec/Product_1P_Device_spec.rb +0 -202
- data/spec/Product_1P_RPC_spec.rb +0 -175
- data/spec/Product_spec.rb +0 -153
- data/spec/Solution-ServiceDevice_spec.rb +0 -176
- data/spec/cmd_assign_spec.rb +0 -51
@@ -0,0 +1,120 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'MrMurano/version'
|
3
|
+
require 'MrMurano/Gateway'
|
4
|
+
require 'MrMurano/SyncRoot'
|
5
|
+
require '_workspace'
|
6
|
+
|
7
|
+
RSpec.describe MrMurano::Gateway::Settings do
|
8
|
+
include_context "WORKSPACE"
|
9
|
+
before(:example) do
|
10
|
+
MrMurano::SyncRoot.instance.reset
|
11
|
+
$cfg = MrMurano::Config.new
|
12
|
+
$cfg.load
|
13
|
+
$cfg['net.host'] = 'bizapi.hosted.exosite.io'
|
14
|
+
$cfg['product.id'] = 'XYZ'
|
15
|
+
|
16
|
+
@gw = MrMurano::Gateway::Settings.new
|
17
|
+
allow(@gw).to receive(:token).and_return("TTTTTTTTTT")
|
18
|
+
|
19
|
+
@infoblob = {
|
20
|
+
:name=>"XXXXXXXX",
|
21
|
+
:protocol=>{:name=>"onep", :devmode=>false},
|
22
|
+
:description=>"XXXXXXXX",
|
23
|
+
:identity_format=> {
|
24
|
+
:prefix=>"", :type=>"opaque", :options=>{:casing=>"mixed", :length=>0}},
|
25
|
+
:fqdn=>"XXXXXXXX.m2.exosite-staging.io",
|
26
|
+
:provisioning=> {
|
27
|
+
:auth_type => 'token',
|
28
|
+
:enabled=>true,
|
29
|
+
:generate_identity=>true,
|
30
|
+
:presenter_identity=>true,
|
31
|
+
:ip_whitelisting=>{:enabled=>false, :allowed=>[]}},
|
32
|
+
:resources=> {
|
33
|
+
:bob=>{:format=>"string", :unit=>"c", :settable=>true},
|
34
|
+
:fuzz=>{:format=>"string", :unit=>"c", :settable=>true},
|
35
|
+
:gruble=>{:format=>"string", :unit=>"bits", :settable=>true}
|
36
|
+
}
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
it "initializes" do
|
41
|
+
uri = @gw.endpoint('/')
|
42
|
+
expect(uri.to_s).to eq("https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2/")
|
43
|
+
end
|
44
|
+
|
45
|
+
context "protocol" do
|
46
|
+
context "reads" do
|
47
|
+
it "data" do
|
48
|
+
stub_request(:get, "https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2").
|
49
|
+
with(:headers => {'Authorization'=>'token TTTTTTTTTT', 'Content-Type'=>'application/json'}).
|
50
|
+
to_return(:status => 200, :body => @infoblob.to_json, :headers => {})
|
51
|
+
|
52
|
+
ret = @gw.protocol
|
53
|
+
expect(ret).to eq(@infoblob[:protocol])
|
54
|
+
end
|
55
|
+
|
56
|
+
it "returns empty if not Hash" do
|
57
|
+
stub_request(:get, "https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2").
|
58
|
+
with(:headers => {'Authorization'=>'token TTTTTTTTTT', 'Content-Type'=>'application/json'}).
|
59
|
+
to_return(:status => 200, :body => ['bob'].to_json, :headers => {})
|
60
|
+
|
61
|
+
ret = @gw.protocol
|
62
|
+
expect(ret).to eq({})
|
63
|
+
end
|
64
|
+
|
65
|
+
it "returns empty if missing protocol" do
|
66
|
+
foo = @infoblob.dup
|
67
|
+
foo.delete :protocol
|
68
|
+
stub_request(:get, "https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2").
|
69
|
+
with(:headers => {'Authorization'=>'token TTTTTTTTTT', 'Content-Type'=>'application/json'}).
|
70
|
+
to_return(:status => 200, :body => foo.to_json, :headers => {})
|
71
|
+
|
72
|
+
ret = @gw.protocol
|
73
|
+
expect(ret).to eq({})
|
74
|
+
end
|
75
|
+
|
76
|
+
it "returns empty if protocol not Hash" do
|
77
|
+
foo = @infoblob.dup
|
78
|
+
foo[:protocol] = "bob"
|
79
|
+
stub_request(:get, "https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2").
|
80
|
+
with(:headers => {'Authorization'=>'token TTTTTTTTTT', 'Content-Type'=>'application/json'}).
|
81
|
+
to_return(:status => 200, :body => foo.to_json, :headers => {})
|
82
|
+
|
83
|
+
ret = @gw.protocol
|
84
|
+
expect(ret).to eq({})
|
85
|
+
end
|
86
|
+
end
|
87
|
+
context "writes" do
|
88
|
+
it "data" do
|
89
|
+
newvalues = {:name=>'twelve', :devmode=>true}
|
90
|
+
stub_request(:patch, "https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2").
|
91
|
+
with(:headers => {'Authorization'=>'token TTTTTTTTTT',
|
92
|
+
'Content-Type'=>'application/json'},
|
93
|
+
:body => {:protocol=>newvalues}.to_json).
|
94
|
+
to_return(:status => 200, :headers => {})
|
95
|
+
|
96
|
+
ret = @gw.protocol=(newvalues)
|
97
|
+
expect(ret).to eq(newvalues)
|
98
|
+
end
|
99
|
+
|
100
|
+
it "raises when not Hash" do
|
101
|
+
expect{ @gw.protocol=('foo') }.to raise_error "Not Hash"
|
102
|
+
end
|
103
|
+
|
104
|
+
it "strips extra keys" do
|
105
|
+
newvalues = {:name=>'twelve', :devmode=>true, :auth=>"yes", :bob=>:built}
|
106
|
+
stub_request(:patch, "https://bizapi.hosted.exosite.io/api:1/service/XYZ/device2").
|
107
|
+
with(:headers => {'Authorization'=>'token TTTTTTTTTT',
|
108
|
+
'Content-Type'=>'application/json'},
|
109
|
+
:body => {:protocol=>{:name=>'twelve', :devmode=>true}}.to_json).
|
110
|
+
to_return(:status => 200, :headers => {})
|
111
|
+
|
112
|
+
ret = @gw.protocol=(newvalues)
|
113
|
+
expect(ret).to eq(newvalues)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
119
|
+
|
120
|
+
# vim: set ai et sw=2 ts=2 :
|
data/spec/Http_spec.rb
CHANGED
@@ -7,10 +7,12 @@ require '_workspace'
|
|
7
7
|
class Tst
|
8
8
|
include MrMurano::Verbose
|
9
9
|
include MrMurano::Http
|
10
|
+
|
10
11
|
def initialize
|
11
12
|
@token = nil
|
12
13
|
end
|
13
14
|
end
|
15
|
+
|
14
16
|
RSpec.describe MrMurano::Http do
|
15
17
|
include_context "WORKSPACE"
|
16
18
|
|
@@ -23,7 +25,8 @@ RSpec.describe MrMurano::Http do
|
|
23
25
|
context "gets a token" do
|
24
26
|
before(:example) do
|
25
27
|
@acc = instance_double("MrMurano::Account")
|
26
|
-
allow(MrMurano::Account).to receive(:new).and_return(@acc)
|
28
|
+
#allow(MrMurano::Account).to receive(:new).and_return(@acc)
|
29
|
+
allow(MrMurano::Account).to receive(:instance).and_return(@acc)
|
27
30
|
end
|
28
31
|
|
29
32
|
it "already has one" do
|
@@ -33,17 +36,21 @@ RSpec.describe MrMurano::Http do
|
|
33
36
|
end
|
34
37
|
|
35
38
|
it "gets one" do
|
39
|
+
#expect(@acc).to receive(:adc_compat_check)
|
36
40
|
expect(@acc).to receive(:token).and_return("ABCDEFG")
|
37
41
|
ret = @tst.token
|
38
42
|
expect(ret).to eq("ABCDEFG")
|
39
43
|
end
|
40
44
|
|
41
|
-
it "raises when
|
45
|
+
it "raises when not logged in" do
|
42
46
|
expect(@acc).to receive(:token).and_return(nil)
|
47
|
+
# 2017-07-13: The token command used to raise an error, but [lb]
|
48
|
+
# doesn't like seeing the "use --trace" message that Ruby spits
|
49
|
+
# out. So write to stderr and exit instead. Here, use check that
|
50
|
+
# the function exits by expecting it to raise SystemExit.
|
43
51
|
expect {
|
44
52
|
@tst.token
|
45
|
-
}.to raise_error "
|
46
|
-
|
53
|
+
}.to raise_error(SystemExit).and output("\e[31mNot logged in!\e[0m\n").to_stderr
|
47
54
|
end
|
48
55
|
end
|
49
56
|
|
@@ -62,25 +69,28 @@ RSpec.describe MrMurano::Http do
|
|
62
69
|
|
63
70
|
it "puts something" do
|
64
71
|
$cfg['tool.curldebug'] = true
|
72
|
+
$cfg.curlfile_f = nil
|
65
73
|
$stdout = StringIO.new
|
66
74
|
@tst.curldebug(@req)
|
67
|
-
expect($stdout.string).to eq(%{curl -s
|
75
|
+
expect($stdout.string).to eq(%{curl -s -H 'User-Agent: test' -H 'Content-Type: application/json' -X GET 'https://test.host/this/is/a/test'\n})
|
68
76
|
end
|
69
77
|
|
70
78
|
it "puts something with Auth" do
|
71
79
|
$cfg['tool.curldebug'] = true
|
80
|
+
$cfg.curlfile_f = nil
|
72
81
|
$stdout = StringIO.new
|
73
82
|
@req['Authorization'] = 'LetMeIn'
|
74
83
|
@tst.curldebug(@req)
|
75
|
-
expect($stdout.string).to eq(%{curl -s
|
84
|
+
expect($stdout.string).to eq(%{curl -s -H 'Authorization: LetMeIn' -H 'User-Agent: test' -H 'Content-Type: application/json' -X GET 'https://test.host/this/is/a/test'\n})
|
76
85
|
end
|
77
86
|
|
78
87
|
it "puts something with Body" do
|
79
88
|
$cfg['tool.curldebug'] = true
|
89
|
+
$cfg.curlfile_f = nil
|
80
90
|
$stdout = StringIO.new
|
81
91
|
@req.body = "builder"
|
82
92
|
@tst.curldebug(@req)
|
83
|
-
expect($stdout.string).to eq(%{curl -s
|
93
|
+
expect($stdout.string).to eq(%{curl -s -H 'User-Agent: test' -H 'Content-Type: application/json' -X GET 'https://test.host/this/is/a/test' -d 'builder'\n})
|
84
94
|
end
|
85
95
|
end
|
86
96
|
|
@@ -191,7 +201,7 @@ RSpec.describe MrMurano::Http do
|
|
191
201
|
idhttp = instance_double('Net::HTTP')
|
192
202
|
expect(idhttp).to receive(:request).once.and_return(@rsp)
|
193
203
|
expect(@tst).to receive(:http).once.and_return(idhttp)
|
194
|
-
expect(@rsp).to receive(:body).
|
204
|
+
expect(@rsp).to receive(:body).and_return(%{{"statusCode": 123, "message": "gone"}})
|
195
205
|
|
196
206
|
@tst.workit(@req)
|
197
207
|
expect($stdout.string).to eq('')
|
data/spec/Mock_spec.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
+
require 'tempfile'
|
1
2
|
require 'MrMurano/Config'
|
2
3
|
require 'MrMurano/Mock'
|
3
|
-
require 'tempfile'
|
4
4
|
require '_workspace'
|
5
5
|
|
6
6
|
RSpec.describe MrMurano::Mock, "#mock" do
|
7
7
|
include_context "WORKSPACE"
|
8
8
|
before(:example) do
|
9
|
-
FileUtils.mkpath(@
|
9
|
+
FileUtils.mkpath(@project_dir + '/routes')
|
10
10
|
$cfg = MrMurano::Config.new
|
11
11
|
$cfg.load
|
12
12
|
|
data/spec/ProjectFile_spec.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
+
#require 'erb'
|
2
|
+
require 'fileutils'
|
3
|
+
#require 'tempfile'
|
1
4
|
require 'MrMurano/version'
|
2
5
|
require 'MrMurano/Config'
|
3
6
|
require 'MrMurano/ProjectFile'
|
4
7
|
require '_workspace'
|
5
|
-
require 'fileutils'
|
6
|
-
#require 'tempfile'
|
7
|
-
#require 'erb'
|
8
8
|
|
9
9
|
RSpec.describe MrMurano::ProjectFile do
|
10
10
|
|
@@ -143,7 +143,7 @@ RSpec.describe MrMurano::ProjectFile do
|
|
143
143
|
context "load just meta" do
|
144
144
|
before(:example) do
|
145
145
|
src = File.join(@testdir, 'spec/fixtures/ProjectFiles/only_meta.yaml')
|
146
|
-
dst = File.join(@
|
146
|
+
dst = File.join(@project_dir, 'meta.murano')
|
147
147
|
FileUtils.copy(src, dst)
|
148
148
|
@pjf.load
|
149
149
|
end
|
@@ -163,7 +163,7 @@ RSpec.describe MrMurano::ProjectFile do
|
|
163
163
|
context "load custom routes" do
|
164
164
|
before(:example) do
|
165
165
|
src = File.join(@testdir, 'spec/fixtures/ProjectFiles/with_routes.yaml')
|
166
|
-
dst = File.join(@
|
166
|
+
dst = File.join(@project_dir, 'meta.murano')
|
167
167
|
FileUtils.copy(src, dst)
|
168
168
|
@pjf.load
|
169
169
|
end
|
@@ -181,7 +181,7 @@ RSpec.describe MrMurano::ProjectFile do
|
|
181
181
|
|
182
182
|
it "reports validation errors" do
|
183
183
|
src = File.join(@testdir, 'spec/fixtures/ProjectFiles/invalid.yaml')
|
184
|
-
dst = File.join(@
|
184
|
+
dst = File.join(@project_dir, 'meta.murano')
|
185
185
|
FileUtils.copy(src, dst)
|
186
186
|
|
187
187
|
saved = $stderr
|
@@ -206,7 +206,7 @@ RSpec.describe MrMurano::ProjectFile do
|
|
206
206
|
|
207
207
|
it "Reports validation errors" do
|
208
208
|
src = File.join(@testdir, 'spec/fixtures/SolutionFiles/0.2.0_invalid.json')
|
209
|
-
dst = File.join(@
|
209
|
+
dst = File.join(@project_dir, 'Solutionfile.json')
|
210
210
|
FileUtils.copy(src, dst)
|
211
211
|
saved = $stderr
|
212
212
|
$stderr = StringIO.new
|
@@ -217,7 +217,7 @@ RSpec.describe MrMurano::ProjectFile do
|
|
217
217
|
|
218
218
|
it "loads with truncated version" do
|
219
219
|
src = File.join(@testdir, 'spec/fixtures/SolutionFiles/0.2.json')
|
220
|
-
dst = File.join(@
|
220
|
+
dst = File.join(@project_dir, 'Solutionfile.json')
|
221
221
|
FileUtils.copy(src, dst)
|
222
222
|
saved = $stderr
|
223
223
|
$stderr = StringIO.new
|
@@ -229,7 +229,7 @@ RSpec.describe MrMurano::ProjectFile do
|
|
229
229
|
context "loads" do
|
230
230
|
before(:example) do
|
231
231
|
src = File.join(@testdir, 'spec/fixtures/SolutionFiles/0.2.0.json')
|
232
|
-
dst = File.join(@
|
232
|
+
dst = File.join(@project_dir, 'Solutionfile.json')
|
233
233
|
FileUtils.copy(src, dst)
|
234
234
|
@pjf.load
|
235
235
|
end
|
@@ -269,7 +269,7 @@ RSpec.describe MrMurano::ProjectFile do
|
|
269
269
|
|
270
270
|
it "Reports validation errors" do
|
271
271
|
src = File.join(@testdir, 'spec/fixtures/SolutionFiles/0.3.0_invalid.json')
|
272
|
-
dst = File.join(@
|
272
|
+
dst = File.join(@project_dir, 'Solutionfile.json')
|
273
273
|
FileUtils.copy(src, dst)
|
274
274
|
saved = $stderr
|
275
275
|
$stderr = StringIO.new
|
@@ -280,7 +280,7 @@ RSpec.describe MrMurano::ProjectFile do
|
|
280
280
|
|
281
281
|
it "loads with truncated version" do
|
282
282
|
src = File.join(@testdir, 'spec/fixtures/SolutionFiles/0.3.json')
|
283
|
-
dst = File.join(@
|
283
|
+
dst = File.join(@project_dir, 'Solutionfile.json')
|
284
284
|
FileUtils.copy(src, dst)
|
285
285
|
saved = $stderr
|
286
286
|
$stderr = StringIO.new
|
@@ -292,7 +292,7 @@ RSpec.describe MrMurano::ProjectFile do
|
|
292
292
|
context "loads" do
|
293
293
|
before(:example) do
|
294
294
|
src = File.join(@testdir, 'spec/fixtures/SolutionFiles/0.3.0.json')
|
295
|
-
dst = File.join(@
|
295
|
+
dst = File.join(@project_dir, 'Solutionfile.json')
|
296
296
|
FileUtils.copy(src, dst)
|
297
297
|
@pjf.load
|
298
298
|
end
|
@@ -309,12 +309,23 @@ RSpec.describe MrMurano::ProjectFile do
|
|
309
309
|
|
310
310
|
it "defines modules" do
|
311
311
|
expect(@pjf['modules.location']).to eq ('.')
|
312
|
-
expect(@pjf['modules.include']).to match_array(
|
312
|
+
expect(@pjf['modules.include']).to match_array(
|
313
|
+
[
|
314
|
+
"modules/debug.lua",
|
315
|
+
"modules/listen.lua",
|
316
|
+
"modules/util.lua",
|
317
|
+
]
|
318
|
+
)
|
313
319
|
end
|
314
320
|
|
315
321
|
it "defines services" do
|
316
322
|
expect(@pjf['services.location']).to eq ('.')
|
317
|
-
expect(@pjf['services.include']).to match_array(
|
323
|
+
expect(@pjf['services.include']).to match_array(
|
324
|
+
[
|
325
|
+
"event_handler/product.lua",
|
326
|
+
"event_handler/timer.lua",
|
327
|
+
]
|
328
|
+
)
|
318
329
|
end
|
319
330
|
|
320
331
|
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
require 'tempfile'
|
2
|
+
require 'yaml'
|
3
|
+
require 'MrMurano/version'
|
4
|
+
require 'MrMurano/ProjectFile'
|
5
|
+
require 'MrMurano/Setting'
|
6
|
+
require 'MrMurano/SyncRoot'
|
7
|
+
require 'MrMurano/SyncUpDown'
|
8
|
+
require '_workspace'
|
9
|
+
|
10
|
+
module ::MrMurano
|
11
|
+
module Testset
|
12
|
+
class Settings
|
13
|
+
def specific
|
14
|
+
end
|
15
|
+
def specific=(x)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
module Testsettwo
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
RSpec.describe MrMurano::Setting do
|
24
|
+
include_context "WORKSPACE"
|
25
|
+
before(:example) do
|
26
|
+
MrMurano::SyncRoot.instance.reset
|
27
|
+
$cfg = MrMurano::Config.new
|
28
|
+
$cfg.load
|
29
|
+
$cfg['net.host'] = 'bizapi.hosted.exosite.io'
|
30
|
+
$cfg['product.id'] = 'XYZ'
|
31
|
+
|
32
|
+
@srv = MrMurano::Setting.new
|
33
|
+
end
|
34
|
+
|
35
|
+
context "maps service name" do
|
36
|
+
it "device2 into Gateway" do
|
37
|
+
ret = @srv.mapservice('device2')
|
38
|
+
expect(ret).to eq('Gateway')
|
39
|
+
end
|
40
|
+
|
41
|
+
it "gaTeWaY into Gateway" do
|
42
|
+
ret = @srv.mapservice('gaTeWaY')
|
43
|
+
expect(ret).to eq('Gateway')
|
44
|
+
end
|
45
|
+
|
46
|
+
it "WeBServICe into Webservice" do
|
47
|
+
ret = @srv.mapservice('WeBServICe')
|
48
|
+
expect(ret).to eq('Webservice')
|
49
|
+
end
|
50
|
+
|
51
|
+
it "bob into Bob" do
|
52
|
+
ret = @srv.mapservice('bob')
|
53
|
+
expect(ret).to eq('Bob')
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context "read" do
|
58
|
+
it "displays error when Service doesn't exist" do
|
59
|
+
expect(@srv).to receive(:error).with("No Settings on \"Fiddlingsticks\"")
|
60
|
+
ret = @srv.read('Fiddlingsticks', 'specific')
|
61
|
+
expect(ret).to be_nil
|
62
|
+
end
|
63
|
+
|
64
|
+
it "displays error when Service doesn't have any Settings" do
|
65
|
+
expect(@srv).to receive(:error).with("No Settings on \"Testsettwo\"")
|
66
|
+
ret = @srv.read('Testsettwo', 'specific')
|
67
|
+
expect(ret).to be_nil
|
68
|
+
end
|
69
|
+
|
70
|
+
it "displays error when Service doesn't have this Setting" do
|
71
|
+
expect(@srv).to receive(:error).with("Unknown setting 'flipit' on 'Testset'")
|
72
|
+
ret = @srv.read('Testset', 'flipit')
|
73
|
+
expect(ret).to be_nil
|
74
|
+
end
|
75
|
+
|
76
|
+
it "the settings" do
|
77
|
+
expect_any_instance_of(MrMurano::Testset::Settings).to receive(:specific).and_return(4)
|
78
|
+
ret = @srv.read('Testset', 'specific')
|
79
|
+
expect(ret).to eq(4)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
context "writes" do
|
84
|
+
it "displays error when Service doesn't exist" do
|
85
|
+
expect(@srv).to receive(:error).with("No Settings on \"Fiddlingsticks\"")
|
86
|
+
ret = @srv.write('Fiddlingsticks', 'specific', 4)
|
87
|
+
expect(ret).to be_nil
|
88
|
+
end
|
89
|
+
|
90
|
+
it "displays error when Service doesn't have any Settings" do
|
91
|
+
expect(@srv).to receive(:error).with("No Settings on \"Testsettwo\"")
|
92
|
+
ret = @srv.write('Testsettwo', 'specific', 4)
|
93
|
+
expect(ret).to be_nil
|
94
|
+
end
|
95
|
+
|
96
|
+
it "displays error when Service doesn't have this Setting" do
|
97
|
+
expect(@srv).to receive(:error).with("Unknown setting 'flipit' on 'Testset'")
|
98
|
+
ret = @srv.write('Testset', 'flipit', 4)
|
99
|
+
expect(ret).to be_nil
|
100
|
+
end
|
101
|
+
|
102
|
+
it "the settings" do
|
103
|
+
expect_any_instance_of(MrMurano::Testset::Settings).to receive(:specific=).with(4).and_return(4)
|
104
|
+
ret = @srv.write('Testset', 'specific', 4)
|
105
|
+
expect(ret).to eq(4)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
# vim: set ai et sw=2 ts=2 :
|