MuranoCLI 3.2.0.beta.9 → 3.2.1.pre.beta.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/Rakefile +5 -0
- data/dockers/README.rst +7 -0
- data/dockers/RELEASE.rst +6 -3
- data/dockers/docker-test.sh +45 -17
- data/docs/completions/murano_completion-bash +211 -86
- data/lib/MrMurano/Account.rb +72 -4
- data/lib/MrMurano/Business.rb +163 -2
- data/lib/MrMurano/Commander-Entry.rb +1 -2
- data/lib/MrMurano/Config.rb +19 -18
- data/lib/MrMurano/Content.rb +26 -19
- data/lib/MrMurano/Gateway.rb +51 -10
- data/lib/MrMurano/ReCommander.rb +1 -1
- data/lib/MrMurano/Solution-Services.rb +80 -35
- data/lib/MrMurano/Solution-Users.rb +1 -0
- data/lib/MrMurano/SyncRoot.rb +10 -3
- data/lib/MrMurano/SyncUpDown-Core.rb +47 -36
- data/lib/MrMurano/SyncUpDown-Item.rb +46 -14
- data/lib/MrMurano/SyncUpDown.rb +22 -20
- data/lib/MrMurano/Webservice-Endpoint.rb +20 -18
- data/lib/MrMurano/Webservice-File.rb +63 -20
- data/lib/MrMurano/commands/business.rb +14 -1
- data/lib/MrMurano/commands/child.rb +148 -0
- data/lib/MrMurano/commands/devices.rb +298 -149
- data/lib/MrMurano/commands/element.rb +2 -1
- data/lib/MrMurano/commands/globals.rb +3 -0
- data/lib/MrMurano/commands/network.rb +152 -33
- data/lib/MrMurano/commands/sync.rb +2 -2
- data/lib/MrMurano/commands.rb +1 -0
- data/lib/MrMurano/verbosing.rb +13 -2
- data/lib/MrMurano/version.rb +1 -1
- data/spec/Account_spec.rb +43 -11
- data/spec/Content_spec.rb +5 -3
- data/spec/GatewayBase_spec.rb +1 -1
- data/spec/GatewayDevice_spec.rb +47 -8
- data/spec/GatewayResource_spec.rb +1 -1
- data/spec/GatewaySettings_spec.rb +1 -1
- data/spec/HttpAuthed_spec.rb +17 -3
- data/spec/ProjectFile_spec.rb +59 -23
- data/spec/Setting_spec.rb +2 -1
- data/spec/Solution-ServiceConfig_spec.rb +1 -1
- data/spec/Solution-ServiceEventHandler_spec.rb +27 -20
- data/spec/Solution-ServiceModules_spec.rb +7 -5
- data/spec/Solution-UsersRoles_spec.rb +7 -1
- data/spec/Solution_spec.rb +9 -1
- data/spec/SyncRoot_spec.rb +5 -5
- data/spec/SyncUpDown_spec.rb +262 -211
- data/spec/Verbosing_spec.rb +49 -8
- data/spec/Webservice-Cors_spec.rb +10 -1
- data/spec/Webservice-Endpoint_spec.rb +84 -65
- data/spec/Webservice-File_spec.rb +16 -11
- data/spec/Webservice-Setting_spec.rb +7 -1
- data/spec/_workspace.rb +9 -0
- data/spec/cmd_business_spec.rb +5 -10
- data/spec/cmd_common.rb +67 -32
- data/spec/cmd_config_spec.rb +9 -14
- data/spec/cmd_content_spec.rb +15 -26
- data/spec/cmd_cors_spec.rb +9 -12
- data/spec/cmd_device_spec.rb +31 -45
- data/spec/cmd_domain_spec.rb +12 -10
- data/spec/cmd_element_spec.rb +18 -17
- data/spec/cmd_exchange_spec.rb +1 -4
- data/spec/cmd_init_spec.rb +56 -72
- data/spec/cmd_keystore_spec.rb +17 -26
- data/spec/cmd_link_spec.rb +13 -17
- data/spec/cmd_password_spec.rb +9 -10
- data/spec/cmd_setting_application_spec.rb +95 -68
- data/spec/cmd_setting_product_spec.rb +59 -37
- data/spec/cmd_status_spec.rb +46 -84
- data/spec/cmd_syncdown_application_spec.rb +28 -50
- data/spec/cmd_syncdown_both_spec.rb +44 -93
- data/spec/cmd_syncdown_unit_spec.rb +858 -0
- data/spec/cmd_syncup_spec.rb +21 -56
- data/spec/cmd_token_spec.rb +0 -3
- data/spec/cmd_usage_spec.rb +15 -10
- data/spec/dry_run_formatter.rb +1 -0
- data/spec/fixtures/dumped_config +4 -4
- data/spec/spec_helper.rb +3 -0
- metadata +4 -2
@@ -75,6 +75,7 @@ RSpec.describe MrMurano::EventHandler do
|
|
75
75
|
event: 'datapoint',
|
76
76
|
created_at: '2016-07-07T19:16:19.479Z',
|
77
77
|
updated_at: '2016-09-12T13:26:55.868Z',
|
78
|
+
header: '--#EVENT device datapoint',
|
78
79
|
script: %{--#EVENT device datapoint
|
79
80
|
-- lua code is here
|
80
81
|
function foo(bar)
|
@@ -330,7 +331,7 @@ end
|
|
330
331
|
end
|
331
332
|
end
|
332
333
|
|
333
|
-
context '
|
334
|
+
context 'to_remote_items' do
|
334
335
|
before(:example) do
|
335
336
|
allow(@srv).to receive(:warning)
|
336
337
|
end
|
@@ -343,17 +344,21 @@ end
|
|
343
344
|
).gsub(/^\s+/, '')
|
344
345
|
tio.close
|
345
346
|
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
347
|
+
want = [
|
348
|
+
{
|
349
|
+
service: 'device',
|
350
|
+
event: 'datapoint',
|
351
|
+
svc_alias: nil,
|
352
|
+
type: nil,
|
353
|
+
line_beg: 1,
|
354
|
+
line_end: 3,
|
355
|
+
local_path: Pathname.new(tio.path),
|
356
|
+
header: %(--#EVENT device datapoint),
|
357
|
+
script: %(-- do something.\nTsdb.write{tags={sn='1'},metrics={[data.alias]=data.value[2]}}\n),
|
358
|
+
},
|
359
|
+
]
|
360
|
+
ret = @srv.to_remote_items(nil, tio.path)
|
361
|
+
expect(ret).to eq(want)
|
357
362
|
end
|
358
363
|
end
|
359
364
|
|
@@ -365,8 +370,8 @@ end
|
|
365
370
|
).gsub(/^\s+/, '')
|
366
371
|
tio.close
|
367
372
|
|
368
|
-
ret = @srv.
|
369
|
-
expect(ret).to eq(
|
373
|
+
ret = @srv.to_remote_items(nil, tio.path)
|
374
|
+
expect(ret).to eq([])
|
370
375
|
end
|
371
376
|
end
|
372
377
|
|
@@ -379,19 +384,21 @@ end
|
|
379
384
|
).gsub(/^\s+/, '')
|
380
385
|
tio.close
|
381
386
|
|
382
|
-
|
383
|
-
expect(ret).to eq(
|
387
|
+
want = [
|
384
388
|
MrMurano::EventHandler::EventHandlerItem.new(
|
385
389
|
service: 'device',
|
386
390
|
event: 'datapoint',
|
387
391
|
svc_alias: nil,
|
388
392
|
type: nil,
|
389
|
-
line_beg:
|
393
|
+
line_beg: 2, # Skips the "-- do something." line, before --#EVENT.
|
390
394
|
line_end: 3,
|
391
395
|
local_path: Pathname.new(tio.path),
|
392
|
-
|
393
|
-
|
394
|
-
|
396
|
+
header: %(--#EVENT device datapoint),
|
397
|
+
script: %(Tsdb.write{tags={sn='1'},metrics={[data.alias]=data.value[2]}}\n),
|
398
|
+
),
|
399
|
+
]
|
400
|
+
ret = @srv.to_remote_items(nil, tio.path)
|
401
|
+
expect(ret).to eq(want)
|
395
402
|
end
|
396
403
|
end
|
397
404
|
end
|
@@ -542,18 +542,20 @@ RSpec.describe MrMurano::Module do
|
|
542
542
|
end
|
543
543
|
end
|
544
544
|
|
545
|
-
context '
|
545
|
+
context 'to_remote_items' do
|
546
546
|
it 'reads one' do
|
547
547
|
root = Pathname.new(@project_dir)
|
548
548
|
path = Pathname.new(@project_dir) + 'test.lua'
|
549
|
-
|
550
|
-
|
549
|
+
want = [{ name: 'test' }]
|
550
|
+
ret = @srv.to_remote_items(root, path)
|
551
|
+
expect(ret).to eq(want)
|
551
552
|
end
|
552
553
|
it 'reads sub folder one' do
|
553
554
|
root = Pathname.new(@project_dir)
|
554
555
|
path = Pathname.new(@project_dir) + 'src/test.lua'
|
555
|
-
ret = @srv.
|
556
|
-
|
556
|
+
ret = @srv.to_remote_items(root, path)
|
557
|
+
want = [{ name: 'src.test' }]
|
558
|
+
expect(ret).to eq(want)
|
557
559
|
end
|
558
560
|
end
|
559
561
|
end
|
@@ -7,6 +7,8 @@
|
|
7
7
|
|
8
8
|
require 'pathname'
|
9
9
|
require 'tempfile'
|
10
|
+
require 'webmock'
|
11
|
+
|
10
12
|
require 'MrMurano/hash'
|
11
13
|
require 'MrMurano/version'
|
12
14
|
require 'MrMurano/HttpAuthed'
|
@@ -17,8 +19,8 @@ require 'HttpAuthed_spec'
|
|
17
19
|
|
18
20
|
RSpec.describe MrMurano::Role do
|
19
21
|
include_context 'WORKSPACE'
|
22
|
+
|
20
23
|
before(:example) do
|
21
|
-
MrMurano::SyncRoot.instance.reset
|
22
24
|
$cfg = MrMurano::Config.new
|
23
25
|
$cfg.load
|
24
26
|
$cfg['net.host'] = 'bizapi.hosted.exosite.io'
|
@@ -29,6 +31,10 @@ RSpec.describe MrMurano::Role do
|
|
29
31
|
MrMurano::HttpAuthed.instance.instance_variable_set(:@token_biz, 'TTTTTTTTTT')
|
30
32
|
end
|
31
33
|
|
34
|
+
after(:example) do
|
35
|
+
WebMock.reset!
|
36
|
+
end
|
37
|
+
|
32
38
|
it 'initializes' do
|
33
39
|
uri = @srv.endpoint('/')
|
34
40
|
expect(uri.to_s).to eq(
|
data/spec/Solution_spec.rb
CHANGED
@@ -6,7 +6,9 @@
|
|
6
6
|
# Unauthorized copying of this file is strictly prohibited.
|
7
7
|
|
8
8
|
require 'tempfile'
|
9
|
+
require 'webmock'
|
9
10
|
require 'yaml'
|
11
|
+
|
10
12
|
require 'MrMurano/version'
|
11
13
|
require 'MrMurano/HttpAuthed'
|
12
14
|
require 'MrMurano/ProjectFile'
|
@@ -17,15 +19,17 @@ require 'HttpAuthed_spec'
|
|
17
19
|
|
18
20
|
RSpec.describe MrMurano::Solution do
|
19
21
|
include_context 'WORKSPACE'
|
22
|
+
|
20
23
|
before(:example) do
|
21
|
-
MrMurano::SyncRoot.instance.reset
|
22
24
|
$cfg = MrMurano::Config.new
|
23
25
|
$cfg.load
|
26
|
+
|
24
27
|
$project = MrMurano::ProjectFile.new
|
25
28
|
$project.load
|
26
29
|
$cfg['net.host'] = 'bizapi.hosted.exosite.io'
|
27
30
|
$cfg['product.id'] = 'XYZ'
|
28
31
|
$cfg['application.id'] = 'XYZ'
|
32
|
+
|
29
33
|
stub_request_email_password
|
30
34
|
|
31
35
|
# NOTE: This test works on either Product or Application.
|
@@ -36,6 +40,10 @@ RSpec.describe MrMurano::Solution do
|
|
36
40
|
MrMurano::HttpAuthed.instance.instance_variable_set(:@token_biz, 'TTTTTTTTTT')
|
37
41
|
end
|
38
42
|
|
43
|
+
after(:example) do
|
44
|
+
WebMock.reset!
|
45
|
+
end
|
46
|
+
|
39
47
|
it 'initializes' do
|
40
48
|
uri = @srv.endpoint('/')
|
41
49
|
expect(uri.to_s).to eq(
|
data/spec/SyncRoot_spec.rb
CHANGED
@@ -15,12 +15,8 @@ require '_workspace'
|
|
15
15
|
RSpec.describe MrMurano::SyncRoot do
|
16
16
|
include_context 'WORKSPACE'
|
17
17
|
|
18
|
-
after(:example) do
|
19
|
-
MrMurano::SyncRoot.instance.reset
|
20
|
-
end
|
21
|
-
|
22
18
|
before(:example) do
|
23
|
-
MrMurano::SyncRoot.instance.reset # also creates @@syncset
|
19
|
+
@syncsetypes = MrMurano::SyncRoot.instance.reset # also creates @@syncset
|
24
20
|
# Weird/2017-07-31: I [lb] must[ve changed something, because this
|
25
21
|
# block being called twice, which is generating a warning:
|
26
22
|
# /exo/clients/exosite/MuranoCLIs/MuranoCLI+landonb/spec/SyncRoot_spec.rb:30:
|
@@ -60,6 +56,10 @@ RSpec.describe MrMurano::SyncRoot do
|
|
60
56
|
end
|
61
57
|
end
|
62
58
|
|
59
|
+
after(:example) do
|
60
|
+
MrMurano::SyncRoot.instance.reset(@syncsetypes)
|
61
|
+
end
|
62
|
+
|
63
63
|
it 'has defaults' do
|
64
64
|
ret = MrMurano::SyncRoot.instance.bydefault
|
65
65
|
expect(ret).to eq(['user'])
|
data/spec/SyncUpDown_spec.rb
CHANGED
@@ -11,7 +11,9 @@ require 'MrMurano/version'
|
|
11
11
|
require 'MrMurano/Config'
|
12
12
|
require 'MrMurano/ProjectFile'
|
13
13
|
require 'MrMurano/SyncRoot'
|
14
|
+
require 'MrMurano/Solution-Services'
|
14
15
|
require 'MrMurano/SyncUpDown'
|
16
|
+
require 'MrMurano/SyncUpDown-Item'
|
15
17
|
require '_workspace'
|
16
18
|
|
17
19
|
class TSUD
|
@@ -35,6 +37,7 @@ class TSUD
|
|
35
37
|
end
|
36
38
|
|
37
39
|
def fetch(id, _untainted=false)
|
40
|
+
# pass
|
38
41
|
end
|
39
42
|
|
40
43
|
def self.description
|
@@ -50,10 +53,27 @@ end
|
|
50
53
|
|
51
54
|
ITEM_UPDATED_AT = '2017-06-24T00:45:15.564Z'
|
52
55
|
|
56
|
+
def expect_status_match_arrs(ret_arr, want_arr)
|
57
|
+
ret_arr.each_with_index do |ret_item, index|
|
58
|
+
want_item = want_arr[index]
|
59
|
+
ret_item.each_pair do |key, val|
|
60
|
+
expect(val).to match(want_item[key])
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def expect_status_match_lkup(ret, want)
|
66
|
+
# Need to tediously iterate, else Item object ID and local_path are flagged.
|
67
|
+
(ret.keys + want.keys).to_set.each do |category|
|
68
|
+
expect(ret[category].length).to eq(want[category].length)
|
69
|
+
expect_status_match_arrs(ret[category], want[category])
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
53
73
|
RSpec.describe MrMurano::SyncUpDown do
|
54
74
|
include_context 'WORKSPACE'
|
75
|
+
|
55
76
|
before(:example) do
|
56
|
-
MrMurano::SyncRoot.instance.reset
|
57
77
|
$cfg = MrMurano::Config.new
|
58
78
|
$cfg.load
|
59
79
|
$project = MrMurano::ProjectFile.new
|
@@ -67,9 +87,9 @@ RSpec.describe MrMurano::SyncUpDown do
|
|
67
87
|
|
68
88
|
context 'status' do
|
69
89
|
it 'warns with missing directory' do
|
70
|
-
|
71
|
-
expect(
|
72
|
-
ret =
|
90
|
+
tsud = TSUD.new
|
91
|
+
expect(tsud).to receive(:warning).once.with(/Skipping missing location.*/)
|
92
|
+
ret = tsud.status
|
73
93
|
expect(ret).to eq(
|
74
94
|
toadd: [], todel: [], tomod: [], unchg: [], skipd: [], clash: []
|
75
95
|
)
|
@@ -77,8 +97,8 @@ RSpec.describe MrMurano::SyncUpDown do
|
|
77
97
|
|
78
98
|
it 'finds nothing in empty directory' do
|
79
99
|
FileUtils.mkpath(@project_dir + '/tsud')
|
80
|
-
|
81
|
-
ret =
|
100
|
+
tsud = TSUD.new
|
101
|
+
ret = tsud.status
|
82
102
|
expect(ret).to eq(
|
83
103
|
toadd: [], todel: [], tomod: [], unchg: [], skipd: [], clash: []
|
84
104
|
)
|
@@ -86,205 +106,218 @@ RSpec.describe MrMurano::SyncUpDown do
|
|
86
106
|
|
87
107
|
it 'finds things there but not here' do
|
88
108
|
FileUtils.mkpath(@project_dir + '/tsud')
|
89
|
-
|
90
|
-
expect(
|
109
|
+
tsud = TSUD.new
|
110
|
+
expect(tsud).to receive(:list).once.and_return(
|
91
111
|
[
|
92
|
-
|
93
|
-
|
94
|
-
|
112
|
+
MrMurano::SyncUpDown::Item.new(name: 1),
|
113
|
+
MrMurano::SyncUpDown::Item.new(name: 2),
|
114
|
+
MrMurano::SyncUpDown::Item.new(name: 3),
|
95
115
|
]
|
96
116
|
)
|
97
|
-
|
98
|
-
expect(ret).to eq(
|
117
|
+
want = {
|
99
118
|
toadd: [],
|
100
119
|
todel: [
|
101
|
-
|
120
|
+
MrMurano::SyncUpDown::Item.new(
|
102
121
|
name: 1,
|
103
122
|
synckey: 1,
|
104
123
|
synctype: TSUD.description,
|
105
|
-
|
106
|
-
|
124
|
+
),
|
125
|
+
MrMurano::SyncUpDown::Item.new(
|
107
126
|
name: 2,
|
108
127
|
synckey: 2,
|
109
128
|
synctype: TSUD.description,
|
110
|
-
|
111
|
-
|
129
|
+
),
|
130
|
+
MrMurano::SyncUpDown::Item.new(
|
112
131
|
name: 3,
|
113
132
|
synckey: 3,
|
114
133
|
synctype: TSUD.description,
|
115
|
-
|
134
|
+
),
|
116
135
|
],
|
117
136
|
tomod: [],
|
118
137
|
unchg: [],
|
119
138
|
skipd: [],
|
120
|
-
clash: []
|
121
|
-
|
139
|
+
clash: [],
|
140
|
+
}
|
141
|
+
ret = tsud.status
|
142
|
+
expect_status_match_lkup(ret, want)
|
122
143
|
end
|
123
144
|
|
124
145
|
it 'finds things there but not here; asdown' do
|
125
146
|
FileUtils.mkpath(@project_dir + '/tsud')
|
126
|
-
|
127
|
-
expect(
|
147
|
+
tsud = TSUD.new
|
148
|
+
expect(tsud).to receive(:list).once.and_return(
|
128
149
|
[
|
129
|
-
|
130
|
-
|
131
|
-
|
150
|
+
MrMurano::SyncUpDown::Item.new(name: 1),
|
151
|
+
MrMurano::SyncUpDown::Item.new(name: 2),
|
152
|
+
MrMurano::SyncUpDown::Item.new(name: 3),
|
132
153
|
]
|
133
154
|
)
|
134
|
-
|
135
|
-
expect(ret).to eq(
|
155
|
+
want = {
|
136
156
|
todel: [],
|
137
157
|
toadd: [
|
138
|
-
|
139
|
-
|
140
|
-
|
158
|
+
MrMurano::SyncUpDown::Item.new(
|
159
|
+
name: 1, synckey: 1, synctype: TSUD.description,
|
160
|
+
),
|
161
|
+
MrMurano::SyncUpDown::Item.new(
|
162
|
+
name: 2, synckey: 2, synctype: TSUD.description,
|
163
|
+
),
|
164
|
+
MrMurano::SyncUpDown::Item.new(
|
165
|
+
name: 3, synckey: 3, synctype: TSUD.description,
|
166
|
+
),
|
141
167
|
],
|
142
168
|
tomod: [],
|
143
169
|
unchg: [],
|
144
170
|
skipd: [],
|
145
|
-
clash: []
|
146
|
-
|
171
|
+
clash: [],
|
172
|
+
}
|
173
|
+
ret = tsud.status(asdown: true)
|
174
|
+
expect_status_match_lkup(ret, want)
|
147
175
|
end
|
148
176
|
|
149
177
|
it 'finds things here but not there' do
|
150
178
|
FileUtils.mkpath(@project_dir + '/tsud')
|
151
179
|
FileUtils.touch(@project_dir + '/tsud/one.lua')
|
152
180
|
FileUtils.touch(@project_dir + '/tsud/two.lua')
|
153
|
-
|
154
|
-
expect(
|
155
|
-
|
156
|
-
name: 'two.lua',
|
181
|
+
tsud = TSUD.new
|
182
|
+
expect(tsud).to receive(:to_remote_items).and_return(
|
183
|
+
[MrMurano::SyncUpDown::Item.new(name: 'one.lua')],
|
184
|
+
[MrMurano::SyncUpDown::Item.new(name: 'two.lua')],
|
157
185
|
)
|
158
|
-
|
159
|
-
expect(ret).to match(
|
186
|
+
want = {
|
160
187
|
toadd: [
|
161
|
-
|
188
|
+
MrMurano::SyncUpDown::Item.new(
|
162
189
|
name: 'one.lua',
|
163
190
|
synckey: 'one.lua',
|
164
191
|
synctype: TSUD.description,
|
165
192
|
local_path: an_instance_of(Pathname),
|
166
|
-
|
167
|
-
|
193
|
+
),
|
194
|
+
MrMurano::SyncUpDown::Item.new(
|
168
195
|
name: 'two.lua',
|
169
196
|
synckey: 'two.lua',
|
170
197
|
synctype: TSUD.description,
|
171
198
|
local_path: an_instance_of(Pathname),
|
172
|
-
|
199
|
+
),
|
173
200
|
],
|
174
201
|
todel: [],
|
175
202
|
tomod: [],
|
176
203
|
unchg: [],
|
177
204
|
skipd: [],
|
178
|
-
clash: []
|
179
|
-
|
205
|
+
clash: [],
|
206
|
+
}
|
207
|
+
ret = tsud.status
|
208
|
+
expect_status_match_lkup(ret, want)
|
180
209
|
end
|
181
210
|
|
182
|
-
it 'finds things here and there' do
|
211
|
+
it 'finds things here and there; and they are different' do
|
183
212
|
FileUtils.mkpath(@project_dir + '/tsud')
|
184
213
|
FileUtils.touch(@project_dir + '/tsud/one.lua')
|
185
214
|
FileUtils.touch(@project_dir + '/tsud/two.lua')
|
186
|
-
|
187
|
-
expect(
|
215
|
+
tsud = TSUD.new
|
216
|
+
expect(tsud).to receive(:list).once.and_return(
|
188
217
|
[
|
189
|
-
|
190
|
-
|
218
|
+
MrMurano::EventHandler::EventHandlerItem.new(name: 'one.lua'),
|
219
|
+
MrMurano::EventHandler::EventHandlerItem.new(name: 'two.lua'),
|
191
220
|
]
|
192
221
|
)
|
193
|
-
expect(
|
194
|
-
|
195
|
-
name: 'two.lua',
|
222
|
+
expect(tsud).to receive(:to_remote_items).and_return(
|
223
|
+
[MrMurano::EventHandler::EventHandlerItem.new(name: 'one.lua')],
|
224
|
+
[MrMurano::EventHandler::EventHandlerItem.new(name: 'two.lua')],
|
196
225
|
)
|
197
|
-
|
198
|
-
expect(ret).to match(
|
226
|
+
want = {
|
199
227
|
tomod: [
|
200
|
-
|
228
|
+
MrMurano::EventHandler::EventHandlerItem.new(
|
201
229
|
name: 'one.lua',
|
202
230
|
synckey: 'one.lua',
|
203
231
|
synctype: TSUD.description,
|
204
232
|
local_path: an_instance_of(Pathname),
|
205
|
-
|
206
|
-
|
233
|
+
),
|
234
|
+
MrMurano::EventHandler::EventHandlerItem.new(
|
207
235
|
name: 'two.lua',
|
208
236
|
synckey: 'two.lua',
|
209
237
|
synctype: TSUD.description,
|
210
238
|
local_path: an_instance_of(Pathname),
|
211
|
-
|
239
|
+
),
|
212
240
|
],
|
213
241
|
todel: [],
|
214
242
|
toadd: [],
|
215
243
|
unchg: [],
|
216
244
|
skipd: [],
|
217
|
-
clash: []
|
218
|
-
|
245
|
+
clash: [],
|
246
|
+
}
|
247
|
+
ret = tsud.status
|
248
|
+
expect_status_match_lkup(ret, want)
|
219
249
|
end
|
250
|
+
|
220
251
|
it "finds things here and there; but they're the same" do
|
221
252
|
FileUtils.mkpath(@project_dir + '/tsud')
|
222
253
|
FileUtils.touch(@project_dir + '/tsud/one.lua')
|
223
254
|
FileUtils.touch(@project_dir + '/tsud/two.lua')
|
224
|
-
|
225
|
-
expect(
|
255
|
+
tsud = TSUD.new
|
256
|
+
expect(tsud).to receive(:list).once.and_return(
|
226
257
|
[
|
227
|
-
|
228
|
-
|
258
|
+
MrMurano::SyncUpDown::Item.new(name: 'one.lua'),
|
259
|
+
MrMurano::SyncUpDown::Item.new(name: 'two.lua'),
|
229
260
|
]
|
230
261
|
)
|
231
|
-
expect(
|
232
|
-
|
233
|
-
name: 'two.lua',
|
262
|
+
expect(tsud).to receive(:to_remote_items).and_return(
|
263
|
+
[MrMurano::SyncUpDown::Item.new(name: 'one.lua')],
|
264
|
+
[MrMurano::SyncUpDown::Item.new(name: 'two.lua')],
|
234
265
|
)
|
235
|
-
expect(
|
236
|
-
|
237
|
-
expect(ret).to match(
|
266
|
+
expect(tsud).to receive(:docmp).twice.and_return(false)
|
267
|
+
want = {
|
238
268
|
unchg: [
|
239
|
-
|
269
|
+
MrMurano::SyncUpDown::Item.new(
|
240
270
|
name: 'one.lua',
|
241
271
|
synckey: 'one.lua',
|
242
272
|
synctype: TSUD.description,
|
243
273
|
local_path: an_instance_of(Pathname),
|
244
|
-
|
245
|
-
|
274
|
+
),
|
275
|
+
MrMurano::SyncUpDown::Item.new(
|
246
276
|
name: 'two.lua',
|
247
277
|
synckey: 'two.lua',
|
248
278
|
synctype: TSUD.description,
|
249
279
|
local_path: an_instance_of(Pathname),
|
250
|
-
|
280
|
+
),
|
251
281
|
],
|
252
282
|
todel: [],
|
253
283
|
toadd: [],
|
254
284
|
tomod: [],
|
255
285
|
skipd: [],
|
256
|
-
clash: []
|
257
|
-
|
286
|
+
clash: [],
|
287
|
+
}
|
288
|
+
ret = tsud.status
|
289
|
+
expect_status_match_lkup(ret, want)
|
258
290
|
end
|
259
291
|
|
260
292
|
it 'calls diff' do
|
261
293
|
FileUtils.mkpath(@project_dir + '/tsud')
|
262
294
|
FileUtils.touch(@project_dir + '/tsud/one.lua')
|
263
|
-
|
264
|
-
expect(
|
265
|
-
|
266
|
-
])
|
267
|
-
expect(t).to receive(:to_remote_item).and_return(
|
268
|
-
name: 'one.lua'
|
295
|
+
tsud = TSUD.new
|
296
|
+
expect(tsud).to receive(:list).once.and_return(
|
297
|
+
[MrMurano::SyncUpDown::Item.new(name: 'one.lua')],
|
269
298
|
)
|
270
|
-
expect(
|
271
|
-
|
272
|
-
|
299
|
+
expect(tsud).to receive(:to_remote_items).and_return(
|
300
|
+
[MrMurano::SyncUpDown::Item.new(name: 'one.lua')]
|
301
|
+
)
|
302
|
+
expect(tsud).to receive(:dodiff).once.and_return('diffed output')
|
303
|
+
want = {
|
273
304
|
tomod: [
|
274
|
-
|
305
|
+
MrMurano::SyncUpDown::Item.new(
|
275
306
|
name: 'one.lua',
|
276
307
|
synckey: 'one.lua',
|
277
308
|
synctype: TSUD.description,
|
278
309
|
local_path: an_instance_of(Pathname),
|
279
310
|
diff: 'diffed output',
|
280
|
-
|
311
|
+
),
|
281
312
|
],
|
282
313
|
todel: [],
|
283
314
|
toadd: [],
|
284
315
|
unchg: [],
|
285
316
|
skipd: [],
|
286
|
-
clash: []
|
287
|
-
|
317
|
+
clash: [],
|
318
|
+
}
|
319
|
+
ret = tsud.status(diff: true)
|
320
|
+
expect_status_match_lkup(ret, want)
|
288
321
|
end
|
289
322
|
|
290
323
|
context 'Filtering' do
|
@@ -297,8 +330,8 @@ RSpec.describe MrMurano::SyncUpDown do
|
|
297
330
|
FileUtils.touch(@project_dir + '/tsud/gb/four.lua') # unchg
|
298
331
|
FileUtils.touch(@project_dir + '/tsud/five.lua') # toadd
|
299
332
|
FileUtils.touch(@project_dir + '/tsud/ga/six.lua') # toadd
|
300
|
-
@
|
301
|
-
expect(@
|
333
|
+
@tsud = TSUD.new
|
334
|
+
expect(@tsud).to receive(:list).once.and_return(
|
302
335
|
[
|
303
336
|
MrMurano::SyncUpDown::Item.new(
|
304
337
|
name: 'eight.lua', updated_at: ITEM_UPDATED_AT
|
@@ -321,65 +354,77 @@ RSpec.describe MrMurano::SyncUpDown do
|
|
321
354
|
]
|
322
355
|
)
|
323
356
|
|
324
|
-
expect(@
|
357
|
+
expect(@tsud).to receive(:to_remote_items)
|
325
358
|
.with(anything, pathname_globs('**/one.lua'))
|
326
359
|
.and_return(
|
327
|
-
|
328
|
-
|
329
|
-
|
360
|
+
[
|
361
|
+
MrMurano::SyncUpDown::Item.new(
|
362
|
+
name: 'one.lua', updated_at: ITEM_UPDATED_AT
|
363
|
+
),
|
364
|
+
]
|
330
365
|
)
|
331
|
-
expect(@
|
366
|
+
expect(@tsud).to receive(:to_remote_items)
|
332
367
|
.with(anything, pathname_globs('**/two.lua'))
|
333
368
|
.and_return(
|
334
|
-
|
335
|
-
|
336
|
-
|
369
|
+
[
|
370
|
+
MrMurano::SyncUpDown::Item.new(
|
371
|
+
name: 'two.lua', updated_at: ITEM_UPDATED_AT
|
372
|
+
),
|
373
|
+
]
|
337
374
|
)
|
338
|
-
expect(@
|
375
|
+
expect(@tsud).to receive(:to_remote_items)
|
339
376
|
.with(anything, pathname_globs('**/three.lua'))
|
340
377
|
.and_return(
|
341
|
-
|
342
|
-
|
343
|
-
|
378
|
+
[
|
379
|
+
MrMurano::SyncUpDown::Item.new(
|
380
|
+
name: 'three.lua', updated_at: ITEM_UPDATED_AT
|
381
|
+
),
|
382
|
+
]
|
344
383
|
)
|
345
|
-
expect(@
|
384
|
+
expect(@tsud).to receive(:to_remote_items)
|
346
385
|
.with(anything, pathname_globs('**/four.lua'))
|
347
386
|
.and_return(
|
348
|
-
|
349
|
-
|
350
|
-
|
387
|
+
[
|
388
|
+
MrMurano::SyncUpDown::Item.new(
|
389
|
+
name: 'four.lua', updated_at: ITEM_UPDATED_AT
|
390
|
+
),
|
391
|
+
]
|
351
392
|
)
|
352
|
-
expect(@
|
393
|
+
expect(@tsud).to receive(:to_remote_items)
|
353
394
|
.with(anything, pathname_globs('**/five.lua'))
|
354
395
|
.and_return(
|
355
|
-
|
356
|
-
|
357
|
-
|
396
|
+
[
|
397
|
+
MrMurano::SyncUpDown::Item.new(
|
398
|
+
name: 'five.lua', updated_at: ITEM_UPDATED_AT
|
399
|
+
),
|
400
|
+
]
|
358
401
|
)
|
359
|
-
expect(@
|
402
|
+
expect(@tsud).to receive(:to_remote_items)
|
360
403
|
.with(anything, pathname_globs('**/six.lua'))
|
361
404
|
.and_return(
|
362
|
-
|
363
|
-
|
364
|
-
|
405
|
+
[
|
406
|
+
MrMurano::SyncUpDown::Item.new(
|
407
|
+
name: 'six.lua', updated_at: ITEM_UPDATED_AT
|
408
|
+
),
|
409
|
+
]
|
365
410
|
)
|
366
411
|
|
367
|
-
expect(@
|
412
|
+
expect(@tsud).to receive(:docmp)
|
368
413
|
.with(have_attributes(name: 'one.lua'), anything)
|
369
414
|
.and_return(true)
|
370
|
-
expect(@
|
415
|
+
expect(@tsud).to receive(:docmp)
|
371
416
|
.with(have_attributes(name: 'two.lua'), anything)
|
372
417
|
.and_return(true)
|
373
|
-
expect(@
|
418
|
+
expect(@tsud).to receive(:docmp)
|
374
419
|
.with(have_attributes(name: 'three.lua'), anything)
|
375
420
|
.and_return(false)
|
376
|
-
expect(@
|
421
|
+
expect(@tsud).to receive(:docmp)
|
377
422
|
.with(have_attributes(name: 'four.lua'), anything)
|
378
423
|
.and_return(false)
|
379
424
|
end
|
380
425
|
|
381
426
|
it 'Returns all with no filter' do
|
382
|
-
ret = @
|
427
|
+
ret = @tsud.status
|
383
428
|
expect(ret).to match(
|
384
429
|
unchg: [
|
385
430
|
have_attributes(
|
@@ -441,7 +486,7 @@ RSpec.describe MrMurano::SyncUpDown do
|
|
441
486
|
end
|
442
487
|
|
443
488
|
it 'Finds local path globs' do
|
444
|
-
ret = @
|
489
|
+
ret = @tsud.status({}, ['**/ga/*.lua'])
|
445
490
|
expect(ret).to match(
|
446
491
|
unchg: [],
|
447
492
|
toadd: [
|
@@ -467,7 +512,7 @@ RSpec.describe MrMurano::SyncUpDown do
|
|
467
512
|
end
|
468
513
|
|
469
514
|
it 'Finds nothing with specific matcher' do
|
470
|
-
ret = @
|
515
|
+
ret = @tsud.status({}, ['#foo'])
|
471
516
|
expect(ret).to match(
|
472
517
|
unchg: [],
|
473
518
|
toadd: [],
|
@@ -479,7 +524,7 @@ RSpec.describe MrMurano::SyncUpDown do
|
|
479
524
|
end
|
480
525
|
|
481
526
|
it 'gets all the details' do
|
482
|
-
ret = @
|
527
|
+
ret = @tsud.status(unselected: true)
|
483
528
|
expect(ret).to match(
|
484
529
|
unchg: [
|
485
530
|
have_attributes(
|
@@ -555,60 +600,58 @@ RSpec.describe MrMurano::SyncUpDown do
|
|
555
600
|
FileUtils.mkpath('tsud')
|
556
601
|
FileUtils.touch('tsud/one.lua')
|
557
602
|
FileUtils.touch('tsud/two.lua')
|
558
|
-
@
|
603
|
+
@tsud = TSUD.new
|
559
604
|
end
|
560
605
|
it 'finds local items' do
|
561
|
-
expect(@
|
562
|
-
|
563
|
-
name: 'two.lua',
|
564
|
-
)
|
565
|
-
ret = @t.localitems(Pathname.new(@project_dir + '/tsud').realpath)
|
566
|
-
expect(ret).to match(
|
567
|
-
[
|
568
|
-
{
|
569
|
-
name: 'one.lua',
|
570
|
-
local_path: an_instance_of(Pathname),
|
571
|
-
},
|
572
|
-
{
|
573
|
-
name: 'two.lua',
|
574
|
-
local_path: an_instance_of(Pathname),
|
575
|
-
},
|
576
|
-
]
|
606
|
+
expect(@tsud).to receive(:to_remote_items).and_return(
|
607
|
+
[MrMurano::SyncUpDown::Item.new(name: 'one.lua')],
|
608
|
+
[MrMurano::SyncUpDown::Item.new(name: 'two.lua')],
|
577
609
|
)
|
610
|
+
want = [
|
611
|
+
MrMurano::SyncUpDown::Item.new(
|
612
|
+
name: 'one.lua',
|
613
|
+
local_path: an_instance_of(Pathname),
|
614
|
+
),
|
615
|
+
MrMurano::SyncUpDown::Item.new(
|
616
|
+
name: 'two.lua',
|
617
|
+
local_path: an_instance_of(Pathname),
|
618
|
+
),
|
619
|
+
]
|
620
|
+
ret = @tsud.localitems(Pathname.new(@project_dir + '/tsud').realpath)
|
621
|
+
expect_status_match_arrs(ret, want)
|
578
622
|
end
|
579
623
|
|
580
|
-
it 'takes an array from
|
581
|
-
expect(@
|
624
|
+
it 'takes an array from to_remote_items' do
|
625
|
+
expect(@tsud).to receive(:to_remote_items).and_return(
|
582
626
|
[
|
583
|
-
|
584
|
-
|
627
|
+
MrMurano::SyncUpDown::Item.new(name: 'one:1'),
|
628
|
+
MrMurano::SyncUpDown::Item.new(name: 'one:2'),
|
585
629
|
],
|
586
630
|
[
|
587
|
-
|
588
|
-
|
631
|
+
MrMurano::SyncUpDown::Item.new(name: 'two:1'),
|
632
|
+
MrMurano::SyncUpDown::Item.new(name: 'two:2'),
|
589
633
|
],
|
590
634
|
)
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
)
|
635
|
+
want = [
|
636
|
+
MrMurano::SyncUpDown::Item.new(
|
637
|
+
name: 'one:1',
|
638
|
+
local_path: an_instance_of(Pathname),
|
639
|
+
),
|
640
|
+
MrMurano::SyncUpDown::Item.new(
|
641
|
+
name: 'one:2',
|
642
|
+
local_path: an_instance_of(Pathname),
|
643
|
+
),
|
644
|
+
MrMurano::SyncUpDown::Item.new(
|
645
|
+
name: 'two:1',
|
646
|
+
local_path: an_instance_of(Pathname),
|
647
|
+
),
|
648
|
+
MrMurano::SyncUpDown::Item.new(
|
649
|
+
name: 'two:2',
|
650
|
+
local_path: an_instance_of(Pathname),
|
651
|
+
),
|
652
|
+
]
|
653
|
+
ret = @tsud.localitems(Pathname.new(@project_dir + '/tsud').realpath)
|
654
|
+
expect_status_match_arrs(ret, want)
|
612
655
|
end
|
613
656
|
end
|
614
657
|
|
@@ -617,24 +660,24 @@ RSpec.describe MrMurano::SyncUpDown do
|
|
617
660
|
FileUtils.mkpath(@project_dir + '/tsud')
|
618
661
|
FileUtils.touch(@project_dir + '/tsud/one.lua')
|
619
662
|
lp = Pathname.new(@project_dir + '/tsud/one.lua').realpath
|
620
|
-
|
621
|
-
expect(
|
622
|
-
|
663
|
+
tsud = TSUD.new
|
664
|
+
expect(tsud).to receive(:fetch).once.with(1, false).and_yield('foo')
|
665
|
+
tsud.download(lp, id: 1, updated_at: ITEM_UPDATED_AT)
|
623
666
|
end
|
624
667
|
end
|
625
668
|
|
626
669
|
context 'doing diffs' do
|
627
670
|
before(:example) do
|
628
671
|
FileUtils.mkpath(@project_dir + '/tsud')
|
629
|
-
@
|
672
|
+
@tsud = TSUD.new
|
630
673
|
@scpt = Pathname.new(@project_dir + '/tsud/one.lua')
|
631
674
|
@scpt.open('w') { |io| io << %(-- fake lua\nreturn 0\n) }
|
632
675
|
@scpt = @scpt.realpath
|
633
676
|
end
|
634
677
|
|
635
678
|
it 'nothing when same.' do
|
636
|
-
expect(@
|
637
|
-
ret = @
|
679
|
+
expect(@tsud).to receive(:fetch).and_yield(%(-- fake lua\nreturn 0\n))
|
680
|
+
ret = @tsud.dodiff(
|
638
681
|
{
|
639
682
|
name: 'one.lua',
|
640
683
|
local_path: @scpt,
|
@@ -650,8 +693,8 @@ RSpec.describe MrMurano::SyncUpDown do
|
|
650
693
|
end
|
651
694
|
|
652
695
|
it 'something when different.' do
|
653
|
-
expect(@
|
654
|
-
ret = @
|
696
|
+
expect(@tsud).to receive(:fetch).and_yield(%(-- fake lua\nreturn 2\n))
|
697
|
+
ret = @tsud.dodiff(
|
655
698
|
{
|
656
699
|
name: 'one.lua',
|
657
700
|
local_path: @scpt,
|
@@ -664,8 +707,8 @@ RSpec.describe MrMurano::SyncUpDown do
|
|
664
707
|
|
665
708
|
it 'uses script in item' do
|
666
709
|
script = %(-- fake lua\nreturn 2\n)
|
667
|
-
expect(@
|
668
|
-
ret = @
|
710
|
+
expect(@tsud).to receive(:fetch).and_yield(script)
|
711
|
+
ret = @tsud.dodiff(
|
669
712
|
{
|
670
713
|
name: 'one.lua',
|
671
714
|
local_path: @scpt,
|
@@ -685,76 +728,79 @@ RSpec.describe MrMurano::SyncUpDown do
|
|
685
728
|
context 'syncup' do
|
686
729
|
before(:example) do
|
687
730
|
FileUtils.mkpath(@project_dir + '/tsud')
|
688
|
-
@
|
731
|
+
@tsud = TSUD.new
|
689
732
|
end
|
690
733
|
|
691
734
|
it 'removes' do
|
692
|
-
expect(@
|
735
|
+
expect(@tsud).to receive(:list).once.and_return(
|
693
736
|
[
|
694
|
-
|
695
|
-
|
696
|
-
|
737
|
+
MrMurano::SyncUpDown::Item.new(name: 1),
|
738
|
+
MrMurano::SyncUpDown::Item.new(name: 2),
|
739
|
+
MrMurano::SyncUpDown::Item.new(name: 3),
|
697
740
|
]
|
698
741
|
)
|
699
|
-
expect(@
|
700
|
-
@
|
742
|
+
expect(@tsud).to receive(:remove).exactly(3).times
|
743
|
+
@tsud.syncup(delete: true)
|
701
744
|
end
|
702
745
|
|
703
746
|
it 'creates' do
|
704
747
|
FileUtils.touch(@project_dir + '/tsud/one.lua')
|
705
748
|
FileUtils.touch(@project_dir + '/tsud/two.lua')
|
706
749
|
|
707
|
-
expect(@
|
708
|
-
|
709
|
-
|
750
|
+
expect(@tsud).to receive(
|
751
|
+
:upload
|
752
|
+
).twice.with(
|
753
|
+
kind_of(Pathname), kind_of(MrMurano::SyncUpDown::Item), false
|
754
|
+
)
|
755
|
+
@tsud.syncup(create: true)
|
710
756
|
end
|
711
757
|
|
712
758
|
it 'updates' do
|
713
759
|
FileUtils.touch(@project_dir + '/tsud/one.lua')
|
714
760
|
FileUtils.touch(@project_dir + '/tsud/two.lua')
|
715
|
-
expect(@
|
761
|
+
expect(@tsud).to receive(:list).once.and_return(
|
716
762
|
[
|
717
763
|
MrMurano::SyncUpDown::Item.new(name: 'one.lua', updated_at: ITEM_UPDATED_AT),
|
718
764
|
MrMurano::SyncUpDown::Item.new(name: 'two.lua', updated_at: ITEM_UPDATED_AT),
|
719
765
|
]
|
720
766
|
)
|
721
767
|
|
722
|
-
expect(@
|
768
|
+
expect(@tsud).to receive(:upload).twice.with(
|
723
769
|
kind_of(Pathname), kind_of(MrMurano::SyncUpDown::Item), true
|
724
770
|
)
|
725
|
-
expect(@
|
726
|
-
|
727
|
-
name: 'two.lua',
|
771
|
+
expect(@tsud).to receive(:to_remote_items).and_return(
|
772
|
+
[MrMurano::SyncUpDown::Item.new(name: 'one.lua')],
|
773
|
+
[MrMurano::SyncUpDown::Item.new(name: 'two.lua')],
|
728
774
|
)
|
729
|
-
@
|
775
|
+
@tsud.syncup(update: true)
|
730
776
|
end
|
731
777
|
end
|
732
778
|
|
733
779
|
context 'syncdown' do
|
734
780
|
before(:example) do
|
735
781
|
FileUtils.mkpath(@project_dir + '/tsud')
|
736
|
-
@
|
782
|
+
@tsud = TSUD.new
|
737
783
|
end
|
738
784
|
|
739
785
|
it 'removes' do
|
740
786
|
FileUtils.touch(@project_dir + '/tsud/one.lua')
|
741
787
|
FileUtils.touch(@project_dir + '/tsud/two.lua')
|
742
788
|
|
743
|
-
@
|
789
|
+
@tsud.syncdown(delete: true)
|
744
790
|
expect(FileTest.exist?(@project_dir + '/tsud/one.lua')).to be false
|
745
791
|
expect(FileTest.exist?(@project_dir + '/tsud/two.lua')).to be false
|
746
792
|
end
|
747
793
|
|
748
794
|
it 'creates' do
|
749
|
-
expect(@
|
795
|
+
expect(@tsud).to receive(:list).once.and_return(
|
750
796
|
[
|
751
797
|
MrMurano::SyncUpDown::Item.new(name: 'one.lua', updated_at: ITEM_UPDATED_AT),
|
752
798
|
MrMurano::SyncUpDown::Item.new(name: 'two.lua', updated_at: ITEM_UPDATED_AT),
|
753
799
|
]
|
754
800
|
)
|
755
801
|
|
756
|
-
expect(@
|
757
|
-
@
|
802
|
+
expect(@tsud).to receive(:fetch).twice.and_yield("--foo\n")
|
803
|
+
@tsud.syncdown(create: true)
|
758
804
|
expect(FileTest.exist?(@project_dir + '/tsud/one.lua')).to be true
|
759
805
|
expect(FileTest.exist?(@project_dir + '/tsud/two.lua')).to be true
|
760
806
|
end
|
@@ -762,19 +808,23 @@ RSpec.describe MrMurano::SyncUpDown do
|
|
762
808
|
it 'updates' do
|
763
809
|
FileUtils.touch(@project_dir + '/tsud/one.lua')
|
764
810
|
FileUtils.touch(@project_dir + '/tsud/two.lua')
|
765
|
-
expect(@
|
811
|
+
expect(@tsud).to receive(:list).once.and_return(
|
766
812
|
[
|
767
813
|
MrMurano::SyncUpDown::Item.new(name: 'one.lua', updated_at: ITEM_UPDATED_AT),
|
768
814
|
MrMurano::SyncUpDown::Item.new(name: 'two.lua', updated_at: ITEM_UPDATED_AT),
|
769
815
|
]
|
770
816
|
)
|
771
817
|
|
772
|
-
expect(@
|
773
|
-
expect(@
|
774
|
-
|
775
|
-
|
818
|
+
expect(@tsud).to receive(:fetch).twice.and_yield("--foo\n")
|
819
|
+
expect(@tsud).to receive(:to_remote_items).and_return(
|
820
|
+
[
|
821
|
+
MrMurano::SyncUpDown::Item.new(name: 'one.lua', updated_at: ITEM_UPDATED_AT),
|
822
|
+
],
|
823
|
+
[
|
824
|
+
MrMurano::SyncUpDown::Item.new(name: 'two.lua', updated_at: ITEM_UPDATED_AT),
|
825
|
+
],
|
776
826
|
)
|
777
|
-
@
|
827
|
+
@tsud.syncdown(update: true)
|
778
828
|
expect(FileTest.exist?(@project_dir + '/tsud/one.lua')).to be true
|
779
829
|
expect(FileTest.exist?(@project_dir + '/tsud/two.lua')).to be true
|
780
830
|
end
|
@@ -784,17 +834,18 @@ RSpec.describe MrMurano::SyncUpDown do
|
|
784
834
|
# before(:example) do
|
785
835
|
# FileUtils.mkpath(@project_dir + '/tsud')
|
786
836
|
# FileUtils.mkpath(@project_dir + '/bundles/mybun/tsud')
|
787
|
-
# @
|
837
|
+
# @tsud = TSUD.new
|
788
838
|
# end
|
789
839
|
#
|
790
840
|
# it "finds items in bundles." do
|
791
841
|
# FileUtils.touch(@project_dir + '/tsud/one.lua')
|
792
842
|
# FileUtils.touch(@project_dir + '/bundles/mybun/tsud/two.lua')
|
793
843
|
#
|
794
|
-
# expect(@
|
795
|
-
# {name: 'two.lua'},
|
844
|
+
# expect(@tsud).to receive(:to_remote_items).and_return(
|
845
|
+
# [{name: 'two.lua'}],
|
846
|
+
# [{name: 'one.lua'}],
|
796
847
|
# )
|
797
|
-
# ret = @
|
848
|
+
# ret = @tsud.locallist
|
798
849
|
# expect(ret).to match([
|
799
850
|
# {name: 'two.lua',
|
800
851
|
# bundled: true,
|
@@ -808,9 +859,9 @@ RSpec.describe MrMurano::SyncUpDown do
|
|
808
859
|
# FileUtils.touch(@project_dir + '/tsud/one.lua')
|
809
860
|
# lp = Pathname.new(@project_dir + '/tsud/one.lua').realpath
|
810
861
|
#
|
811
|
-
# expect(@
|
862
|
+
# expect(@tsud).to receive(:warning).once.with(/Not downloading into bundled item.*/)
|
812
863
|
#
|
813
|
-
# @
|
864
|
+
# @tsud.download(lp, {bundled: true, name: 'one.lua'})
|
814
865
|
# end
|
815
866
|
# end
|
816
867
|
end
|