Skip to content

Commit fbe415d

Browse files
committed
Remove misleading test case
1 parent 8df0043 commit fbe415d

File tree

1 file changed

+49
-77
lines changed

1 file changed

+49
-77
lines changed

pr-checks/test_sync_back.py

Lines changed: 49 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,22 @@
1212

1313

1414
class TestSyncBack(unittest.TestCase):
15-
15+
1616
def setUp(self):
1717
"""Set up temporary directories and files for testing"""
1818
self.test_dir = tempfile.mkdtemp()
1919
self.workflow_dir = os.path.join(self.test_dir, ".github", "workflows")
2020
self.checks_dir = os.path.join(self.test_dir, "pr-checks", "checks")
2121
os.makedirs(self.workflow_dir)
2222
os.makedirs(self.checks_dir)
23-
23+
2424
# Create sync.py file
2525
self.sync_py_path = os.path.join(self.test_dir, "pr-checks", "sync.py")
26-
26+
2727
def tearDown(self):
2828
"""Clean up temporary directories"""
2929
shutil.rmtree(self.test_dir)
30-
30+
3131
def test_scan_generated_workflows_basic(self):
3232
"""Test basic workflow scanning functionality"""
3333
# Create a test generated workflow file
@@ -41,16 +41,16 @@ def test_scan_generated_workflows_basic(self):
4141
- uses: actions/setup-node@v5
4242
- uses: actions/setup-go@v6
4343
"""
44-
44+
4545
with open(os.path.join(self.workflow_dir, "__test.yml"), 'w') as f:
4646
f.write(workflow_content)
47-
47+
4848
result = sync_back.scan_generated_workflows(self.workflow_dir)
49-
49+
5050
self.assertEqual(result['actions/checkout'], 'v4')
5151
self.assertEqual(result['actions/setup-node'], 'v5')
5252
self.assertEqual(result['actions/setup-go'], 'v6')
53-
53+
5454
def test_scan_generated_workflows_with_comments(self):
5555
"""Test scanning workflows with version comments"""
5656
workflow_content = """
@@ -63,16 +63,16 @@ def test_scan_generated_workflows_with_comments(self):
6363
- uses: ruby/setup-ruby@44511735964dcb71245e7e55f72539531f7bc0eb # v1.257.0
6464
- uses: actions/setup-python@v6 # Latest Python
6565
"""
66-
66+
6767
with open(os.path.join(self.workflow_dir, "__test.yml"), 'w') as f:
6868
f.write(workflow_content)
69-
69+
7070
result = sync_back.scan_generated_workflows(self.workflow_dir)
71-
71+
7272
self.assertEqual(result['actions/checkout'], 'v4')
7373
self.assertEqual(result['ruby/setup-ruby'], '44511735964dcb71245e7e55f72539531f7bc0eb # v1.257.0')
7474
self.assertEqual(result['actions/setup-python'], 'v6 # Latest Python')
75-
75+
7676
def test_scan_generated_workflows_ignores_local_actions(self):
7777
"""Test that local actions (starting with ./) are ignored"""
7878
workflow_content = """
@@ -85,45 +85,17 @@ def test_scan_generated_workflows_ignores_local_actions(self):
8585
- uses: ./.github/actions/local-action
8686
- uses: ./another-local-action@v1
8787
"""
88-
88+
8989
with open(os.path.join(self.workflow_dir, "__test.yml"), 'w') as f:
9090
f.write(workflow_content)
91-
91+
9292
result = sync_back.scan_generated_workflows(self.workflow_dir)
93-
93+
9494
self.assertEqual(result['actions/checkout'], 'v4')
9595
self.assertNotIn('./.github/actions/local-action', result)
9696
self.assertNotIn('./another-local-action', result)
97-
98-
def test_scan_generated_workflows_skips_non_generated(self):
99-
"""Test that non-generated files are ignored"""
100-
# Create generated file
101-
generated_content = """
102-
name: Generated
103-
jobs:
104-
test:
105-
steps:
106-
- uses: actions/checkout@v4
107-
"""
108-
with open(os.path.join(self.workflow_dir, "__generated.yml"), 'w') as f:
109-
f.write(generated_content)
110-
111-
# Create regular file
112-
regular_content = """
113-
name: Regular
114-
jobs:
115-
test:
116-
steps:
117-
- uses: actions/checkout@v3
118-
"""
119-
with open(os.path.join(self.workflow_dir, "regular.yml"), 'w') as f:
120-
f.write(regular_content)
121-
122-
result = sync_back.scan_generated_workflows(self.workflow_dir)
123-
124-
# Should only see the version from the generated file
125-
self.assertEqual(result['actions/checkout'], 'v4')
126-
97+
98+
12799
def test_update_sync_py(self):
128100
"""Test updating sync.py file"""
129101
sync_py_content = """
@@ -133,29 +105,29 @@ def test_update_sync_py(self):
133105
'with': {'node-version': '16'}
134106
},
135107
{
136-
'uses': 'actions/setup-go@v5',
108+
'uses': 'actions/setup-go@v5',
137109
'with': {'go-version': '1.19'}
138110
}
139111
]
140112
"""
141-
113+
142114
with open(self.sync_py_path, 'w') as f:
143115
f.write(sync_py_content)
144-
116+
145117
action_versions = {
146118
'actions/setup-node': 'v5',
147119
'actions/setup-go': 'v6'
148120
}
149-
121+
150122
result = sync_back.update_sync_py(self.sync_py_path, action_versions)
151123
self.assertTrue(result)
152-
124+
153125
with open(self.sync_py_path, 'r') as f:
154126
updated_content = f.read()
155-
127+
156128
self.assertIn("'uses': 'actions/setup-node@v5'", updated_content)
157129
self.assertIn("'uses': 'actions/setup-go@v6'", updated_content)
158-
130+
159131
def test_update_sync_py_with_comments(self):
160132
"""Test updating sync.py file when versions have comments"""
161133
sync_py_content = """
@@ -166,24 +138,24 @@ def test_update_sync_py_with_comments(self):
166138
}
167139
]
168140
"""
169-
141+
170142
with open(self.sync_py_path, 'w') as f:
171143
f.write(sync_py_content)
172-
144+
173145
action_versions = {
174146
'actions/setup-node': 'v5 # Latest version'
175147
}
176-
148+
177149
result = sync_back.update_sync_py(self.sync_py_path, action_versions)
178150
self.assertTrue(result)
179-
151+
180152
with open(self.sync_py_path, 'r') as f:
181153
updated_content = f.read()
182-
154+
183155
# sync.py should get the version without comment
184156
self.assertIn("'uses': 'actions/setup-node@v5'", updated_content)
185157
self.assertNotIn("# Latest version", updated_content)
186-
158+
187159
def test_update_template_files(self):
188160
"""Test updating template files"""
189161
template_content = """
@@ -194,50 +166,50 @@ def test_update_template_files(self):
194166
with:
195167
node-version: 16
196168
"""
197-
169+
198170
template_path = os.path.join(self.checks_dir, "test.yml")
199171
with open(template_path, 'w') as f:
200172
f.write(template_content)
201-
173+
202174
action_versions = {
203175
'actions/checkout': 'v4',
204176
'actions/setup-node': 'v5 # Latest'
205177
}
206-
178+
207179
result = sync_back.update_template_files(self.checks_dir, action_versions)
208180
self.assertEqual(len(result), 1)
209181
self.assertIn(template_path, result)
210-
182+
211183
with open(template_path, 'r') as f:
212184
updated_content = f.read()
213-
185+
214186
self.assertIn("uses: actions/checkout@v4", updated_content)
215187
self.assertIn("uses: actions/setup-node@v5 # Latest", updated_content)
216-
188+
217189
def test_update_template_files_preserves_comments(self):
218190
"""Test that updating template files preserves version comments"""
219191
template_content = """
220192
name: Test Template
221193
steps:
222194
- uses: ruby/setup-ruby@44511735964dcb71245e7e55f72539531f7bc0eb # v1.256.0
223195
"""
224-
196+
225197
template_path = os.path.join(self.checks_dir, "test.yml")
226198
with open(template_path, 'w') as f:
227199
f.write(template_content)
228-
200+
229201
action_versions = {
230202
'ruby/setup-ruby': '55511735964dcb71245e7e55f72539531f7bc0eb # v1.257.0'
231203
}
232-
204+
233205
result = sync_back.update_template_files(self.checks_dir, action_versions)
234206
self.assertEqual(len(result), 1)
235-
207+
236208
with open(template_path, 'r') as f:
237209
updated_content = f.read()
238-
210+
239211
self.assertIn("uses: ruby/setup-ruby@55511735964dcb71245e7e55f72539531f7bc0eb # v1.257.0", updated_content)
240-
212+
241213
def test_no_changes_needed(self):
242214
"""Test that functions return False/empty when no changes are needed"""
243215
# Test sync.py with no changes needed
@@ -249,22 +221,22 @@ def test_no_changes_needed(self):
249221
}
250222
]
251223
"""
252-
224+
253225
with open(self.sync_py_path, 'w') as f:
254226
f.write(sync_py_content)
255-
227+
256228
action_versions = {
257229
'actions/setup-node': 'v5'
258230
}
259-
231+
260232
result = sync_back.update_sync_py(self.sync_py_path, action_versions)
261233
self.assertFalse(result)
262-
234+
263235
def test_missing_sync_py_file(self):
264236
"""Test handling of missing sync.py file"""
265237
result = sync_back.update_sync_py("/nonexistent/sync.py", {})
266238
self.assertFalse(result)
267-
239+
268240
def test_main_dry_run(self):
269241
"""Test that dry-run functionality works"""
270242
# Create a test workflow
@@ -275,10 +247,10 @@ def test_main_dry_run(self):
275247
steps:
276248
- uses: actions/checkout@v4
277249
"""
278-
250+
279251
with open(os.path.join(self.workflow_dir, "__test.yml"), 'w') as f:
280252
f.write(workflow_content)
281-
253+
282254
# Test the scanning function directly since mocking main() is complex
283255
result = sync_back.scan_generated_workflows(self.workflow_dir)
284256
self.assertIn('actions/checkout', result)

0 commit comments

Comments
 (0)