31
31
size_comparison_tolerance = 0.03 # Maximum allowed archive size difference ratio
32
32
33
33
34
- def test_sync (run_command , working_dir ):
35
- working_dir_path = pathlib .Path (working_dir )
36
- configuration = {
37
- "BaseDownloadUrl" : "http://www.example.com/libraries/" ,
38
- "LibrariesFolder" : working_dir_path .joinpath ("libraries" ).as_posix (),
39
- "LogsFolder" : working_dir_path .joinpath ("logs" ).as_posix (),
40
- "LibrariesDB" : working_dir_path .joinpath ("libraries_db.json" ).as_posix (),
41
- "LibrariesIndex" : working_dir_path .joinpath ("libraries" , "library_index.json" ).as_posix (),
42
- "GitClonesFolder" : working_dir_path .joinpath ("gitclones" ).as_posix (),
43
- # I was unable to get clamdscan working in the GitHub Actions runner, but the tests should pass with this set to
44
- # False when run on a machine with ClamAV installed.
45
- "DoNotRunClamav" : True ,
46
- # Arduino Lint should be installed under PATH
47
- "ArduinoLintPath" : "" ,
48
- }
49
-
50
- # Generate configuration file
51
- with working_dir_path .joinpath ("config.json" ).open ("w" , encoding = "utf-8" ) as configuration_file :
52
- json .dump (obj = configuration , fp = configuration_file , indent = 2 )
53
-
34
+ def test_sync (configuration , run_command ):
54
35
libraries_repository_engine_command = [
55
36
"sync" ,
56
37
"--config-file" ,
57
- working_dir_path . joinpath ( "config.json" ) ,
38
+ configuration . path ,
58
39
test_data_path .joinpath ("test_sync" , "repos.txt" ),
59
40
]
60
41
@@ -63,38 +44,38 @@ def test_sync(run_command, working_dir):
63
44
assert result .ok
64
45
65
46
# Test fresh output
66
- check_libraries (configuration = configuration )
47
+ check_libraries (configuration = configuration . data )
67
48
check_logs (
68
- configuration = configuration ,
49
+ configuration = configuration . data ,
69
50
golden_logs_parent_path = test_data_path .joinpath ("test_sync" , "golden" , "logs" , "generate" ),
70
51
logs_subpath = pathlib .Path ("github.com" , "arduino-libraries" , "ArduinoCloudThing" , "index.html" ),
71
52
)
72
53
check_logs (
73
- configuration = configuration ,
54
+ configuration = configuration . data ,
74
55
golden_logs_parent_path = test_data_path .joinpath ("test_sync" , "golden" , "logs" , "generate" ),
75
56
logs_subpath = pathlib .Path ("github.com" , "arduino-libraries" , "SpacebrewYun" , "index.html" ),
76
57
)
77
- check_db (configuration = configuration )
78
- check_index (configuration = configuration )
58
+ check_db (configuration = configuration . data )
59
+ check_index (configuration = configuration . data )
79
60
80
61
# Run the engine again
81
62
result = run_command (cmd = libraries_repository_engine_command )
82
63
assert result .ok
83
64
84
65
# Test the updated output
85
- check_libraries (configuration = configuration )
66
+ check_libraries (configuration = configuration . data )
86
67
check_logs (
87
- configuration = configuration ,
68
+ configuration = configuration . data ,
88
69
golden_logs_parent_path = test_data_path .joinpath ("test_sync" , "golden" , "logs" , "update" ),
89
70
logs_subpath = pathlib .Path ("github.com" , "arduino-libraries" , "ArduinoCloudThing" , "index.html" ),
90
71
)
91
72
check_logs (
92
- configuration = configuration ,
73
+ configuration = configuration . data ,
93
74
golden_logs_parent_path = test_data_path .joinpath ("test_sync" , "golden" , "logs" , "update" ),
94
75
logs_subpath = pathlib .Path ("github.com" , "arduino-libraries" , "SpacebrewYun" , "index.html" ),
95
76
)
96
- check_db (configuration = configuration )
97
- check_index (configuration = configuration )
77
+ check_db (configuration = configuration . data )
78
+ check_index (configuration = configuration . data )
98
79
99
80
100
81
def check_libraries (configuration ):
@@ -276,28 +257,11 @@ def check_index(configuration):
276
257
277
258
278
259
# The engine's Git code struggles to get a clean checkout of releases under some circumstances.
279
- def test_clean_checkout (run_command , working_dir ):
280
- working_dir_path = pathlib .Path (working_dir )
281
- configuration = {
282
- "BaseDownloadUrl" : "http://www.example.com/libraries/" ,
283
- "LibrariesFolder" : working_dir_path .joinpath ("libraries" ).as_posix (),
284
- "LogsFolder" : working_dir_path .joinpath ("logs" ).as_posix (),
285
- "LibrariesDB" : working_dir_path .joinpath ("libraries_db.json" ).as_posix (),
286
- "LibrariesIndex" : working_dir_path .joinpath ("libraries" , "library_index.json" ).as_posix (),
287
- "GitClonesFolder" : working_dir_path .joinpath ("gitclones" ).as_posix (),
288
- "DoNotRunClamav" : True ,
289
- # Arduino Lint should be installed under PATH
290
- "ArduinoLintPath" : "" ,
291
- }
292
-
293
- # Generate configuration file
294
- with working_dir_path .joinpath ("config.json" ).open ("w" , encoding = "utf-8" ) as configuration_file :
295
- json .dump (obj = configuration , fp = configuration_file , indent = 2 )
296
-
260
+ def test_clean_checkout (configuration , run_command ):
297
261
libraries_repository_engine_command = [
298
262
"sync" ,
299
263
"--config-file" ,
300
- working_dir_path . joinpath ( "config.json" ) ,
264
+ configuration . path ,
301
265
test_data_path .joinpath ("test_clean_checkout" , "repos.txt" ),
302
266
]
303
267
@@ -306,7 +270,7 @@ def test_clean_checkout(run_command, working_dir):
306
270
assert result .ok
307
271
308
272
# Load generated index
309
- with pathlib .Path (configuration ["LibrariesIndex" ]).open (mode = "r" , encoding = "utf-8" ) as library_index_file :
273
+ with pathlib .Path (configuration . data ["LibrariesIndex" ]).open (mode = "r" , encoding = "utf-8" ) as library_index_file :
310
274
library_index = json .load (fp = library_index_file )
311
275
312
276
for release in library_index ["libraries" ]:
0 commit comments