Skip to content

Commit 78b594f

Browse files
committed
test: don't use duplicate labels
1 parent af329e6 commit 78b594f

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

test/test_transforms_cached_tasks.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def assert_cache_basic(tasks):
5555
def assert_cache_with_dependency(tasks):
5656
handle_exception(tasks)
5757
assert len(tasks) == 2
58+
tasks = sorted(tasks, key=lambda t: t["label"])
5859
assert tasks[1] == {
5960
"attributes": {
6061
"cached_task": {
@@ -65,7 +66,7 @@ def assert_cache_with_dependency(tasks):
6566
},
6667
"dependencies": {"edge": "dep-cached"},
6768
"description": "description",
68-
"label": "cached-task",
69+
"label": "cached-with-dep",
6970
"optimization": {
7071
"index-search": [
7172
"test-domain.cache.level-3.cached-task.v2.cache-foo.hash.db201e53944fccbb16736c8153a14de39748c0d290de84bd976c11ddcc413089",
@@ -92,15 +93,16 @@ def assert_cache_with_non_cached_dependency(e):
9293

9394
def assert_chain_of_trust_influences_digest(tasks):
9495
assert len(tasks) == 3
95-
# The first two tasks are chain-of-trust unspecified, and chain-of-trust: False
96+
tasks = sorted(tasks, key=lambda t: t["label"]) # cot-false, cot-true, no-cot
97+
# The first and third tasks are chain-of-trust: false, and chain-of-trust unspecified
9698
# which should result in the same digest.
9799
digest_0 = tasks[0]["attributes"]["cached_task"]["digest"]
98-
digest_1 = tasks[1]["attributes"]["cached_task"]["digest"]
99-
assert digest_0 == digest_1
100-
101-
# The third task is chain-of-trust: True, and should have a different digest
102100
digest_2 = tasks[2]["attributes"]["cached_task"]["digest"]
103-
assert digest_0 != digest_2
101+
assert digest_0 == digest_2
102+
103+
# The second task is chain-of-trust: True, and should have a different digest
104+
digest_1 = tasks[1]["attributes"]["cached_task"]["digest"]
105+
assert digest_0 != digest_1
104106

105107

106108
@pytest.mark.parametrize(
@@ -141,7 +143,8 @@ def assert_chain_of_trust_influences_digest(tasks):
141143
"type": "cached-task.v2",
142144
"name": "cache-foo",
143145
"digest-data": ["abc"],
144-
}
146+
},
147+
"label": "cached-no-dep",
145148
},
146149
# This task has same digest-data, but a dependency on a cached task.
147150
{
@@ -151,6 +154,7 @@ def assert_chain_of_trust_influences_digest(tasks):
151154
"digest-data": ["abc"],
152155
},
153156
"dependencies": {"edge": "dep-cached"},
157+
"label": "cached-with-dep",
154158
},
155159
],
156160
# kind config
@@ -198,6 +202,7 @@ def assert_chain_of_trust_influences_digest(tasks):
198202
"name": "cache-foo",
199203
"digest-data": ["abc"],
200204
},
205+
"label": "no-cot",
201206
# no explicit chain of trust configuration; should be the
202207
# same as when it is set to False
203208
},
@@ -207,6 +212,7 @@ def assert_chain_of_trust_influences_digest(tasks):
207212
"name": "cache-foo",
208213
"digest-data": ["abc"],
209214
},
215+
"label": "cot-false",
210216
"worker": {
211217
"chain-of-trust": False,
212218
},
@@ -217,6 +223,7 @@ def assert_chain_of_trust_influences_digest(tasks):
217223
"name": "cache-foo",
218224
"digest-data": ["abc"],
219225
},
226+
"label": "cot-true",
220227
"worker": {"chain-of-trust": True},
221228
},
222229
],

0 commit comments

Comments
 (0)