Skip to content

Commit f7d3b47

Browse files
committed
test(caches): add a test for disabled caches
1 parent b4ad85c commit f7d3b47

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

test/test_transforms_run.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ def transform(monkeypatch, run_transform):
4747
monkeypatch.setenv("TASK_ID", "fakeid")
4848

4949
def inner(task_input):
50-
task = deepcopy(TASK_DEFAULTS)
51-
task.update(task_input)
50+
defaults = deepcopy(TASK_DEFAULTS)
51+
task = merge(defaults, task_input)
5252

5353
with patch("taskgraph.transforms.run.configure_taskdesc_for_run") as m:
5454
# This forces the generator to be evaluated
@@ -68,14 +68,18 @@ def inner(task):
6868
if impl not in ("docker-worker", "generic-worker"):
6969
pytest.xfail(f"caches not implemented for '{impl}'")
7070

71-
# Create a new schema object with just the part relevant to caches.
7271
key = "caches" if impl == "docker-worker" else "mounts"
73-
partial_schema = Schema(payload_builders[impl].schema.schema[key])
74-
validate_schema(partial_schema, taskdesc["worker"][key], "validation error")
7572

7673
result = taskdesc["worker"].get(key)
77-
print("Dumping for copy/paste:")
78-
pprint(result, indent=2)
74+
75+
if result:
76+
print("Dumping for copy/paste:")
77+
pprint(result, indent=2)
78+
79+
# Create a new schema object with just the part relevant to caches.
80+
partial_schema = Schema(payload_builders[impl].schema.schema[key])
81+
validate_schema(partial_schema, taskdesc["worker"][key], "validation error")
82+
7983
return result
8084

8185
return inner
@@ -105,6 +109,13 @@ def test_caches_generic_worker(run_caches):
105109
]
106110

107111

112+
@pytest.mark.parametrize("worker_type", ("t-linux", "t-win"))
113+
def test_caches_disabled(run_caches, worker_type):
114+
assert (
115+
run_caches({"run": {"use-caches": False}, "worker-type": worker_type}) is None
116+
)
117+
118+
108119
def test_rewrite_when_to_optimization(run_transform, make_transform_config):
109120
config = make_transform_config()
110121

0 commit comments

Comments
 (0)