File tree 3 files changed +28
-2
lines changed
snippets/instances/create_start_instance
3 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -90,6 +90,7 @@ def __repr__(self):
90
90
re .compile (r".*requirements-test\.txt$" ),
91
91
re .compile (r".*?/tests/.*" ),
92
92
re .compile (r".*?/__pycache__/.*" ),
93
+ re .compile (r".*?sponge_log.xml.*" ),
93
94
)
94
95
95
96
Original file line number Diff line number Diff line change 30
30
31
31
def get_disk (project_id : str , zone : str , disk_name : str ) -> compute_v1 .Disk :
32
32
"""
33
- Deletes a disk from a project.
33
+ Gets a disk from a project.
34
34
35
35
Args:
36
36
project_id: project ID or project number of the Cloud project you want to use.
37
- zone: name of the zone in which is the disk you want to delete .
37
+ zone: name of the zone where the disk exists .
38
38
disk_name: name of the disk you want to retrieve.
39
39
"""
40
40
disk_client = compute_v1 .DisksClient ()
Original file line number Diff line number Diff line change 16
16
from pathlib import Path
17
17
import tempfile
18
18
19
+ import pytest
20
+
19
21
from . import sgs
20
22
21
23
FIXTURE_INGREDIENTS = Path ("sgs_test_fixtures/ingredients" )
@@ -30,3 +32,26 @@ def test_sgs_generate():
30
32
for test_file in map (Path , glob .glob (f"{ tmp_dir } /**" )):
31
33
match_file = FIXTURE_OUTPUT / test_file .relative_to (tmp_dir )
32
34
assert test_file .read_bytes () == match_file .read_bytes ()
35
+
36
+
37
+ def test_snippets_freshness ():
38
+ """
39
+ Make sure that the snippets/ folder is up-to-date and matches
40
+ ingredients/ and recipes/. This test will generate SGS output
41
+ in a temporary directory and compare it to the content of
42
+ snippets/ folder.
43
+ """
44
+ with tempfile .TemporaryDirectory () as tmp_dir :
45
+ args = Namespace (output_dir = tmp_dir )
46
+ sgs .generate (args , Path ("ingredients/" ).absolute (), Path ("recipes/" ).absolute ())
47
+ print (list (map (Path , glob .glob (f"{ tmp_dir } /**" ))))
48
+ for test_file in map (Path , glob .glob (f"{ tmp_dir } /**" , recursive = True )):
49
+ match_file = Path ("snippets/" ) / test_file .relative_to (tmp_dir )
50
+ if test_file .is_file ():
51
+ if test_file .read_bytes () != match_file .read_bytes ():
52
+ pytest .fail (
53
+ f"This test fails because file { match_file } seems to be outdated. Please run "
54
+ f"`python sgs.py generate` to update your snippets."
55
+ )
56
+ elif test_file .is_dir ():
57
+ assert match_file .is_dir ()
You can’t perform that action at this time.
0 commit comments