... |
... |
@@ -139,6 +139,82 @@ def test_mirror_fetch(cli, tmpdir, datafiles, kind): |
139
|
139
|
result.assert_success()
|
140
|
140
|
|
141
|
141
|
|
|
142
|
+@pytest.mark.datafiles(DATA_DIR)
|
|
143
|
+@pytest.mark.parametrize("ref_storage", [("inline"), ("project.refs")])
|
|
144
|
+@pytest.mark.parametrize("mirror", [("no-mirror"), ("mirror"), ("unrelated-mirror")])
|
|
145
|
+def test_mirror_fetch_ref_storage(cli, tmpdir, datafiles, ref_storage, mirror):
|
|
146
|
+ bin_files_path = os.path.join(str(datafiles), 'files', 'bin-files', 'usr')
|
|
147
|
+ dev_files_path = os.path.join(str(datafiles), 'files', 'dev-files', 'usr')
|
|
148
|
+ upstream_repodir = os.path.join(str(tmpdir), 'upstream')
|
|
149
|
+ mirror_repodir = os.path.join(str(tmpdir), 'mirror')
|
|
150
|
+ project_dir = os.path.join(str(tmpdir), 'project')
|
|
151
|
+ os.makedirs(project_dir)
|
|
152
|
+ element_dir = os.path.join(project_dir, 'elements')
|
|
153
|
+
|
|
154
|
+ # Create repo objects of the upstream and mirror
|
|
155
|
+ upstream_repo = create_repo('git', upstream_repodir)
|
|
156
|
+ upstream_ref = upstream_repo.create(bin_files_path)
|
|
157
|
+ mirror_repo = upstream_repo.copy(mirror_repodir)
|
|
158
|
+ mirror_ref = upstream_ref
|
|
159
|
+ upstream_ref = upstream_repo.create(dev_files_path)
|
|
160
|
+
|
|
161
|
+ element = {
|
|
162
|
+ 'kind': 'import',
|
|
163
|
+ 'sources': [
|
|
164
|
+ upstream_repo.source_config(ref=upstream_ref if ref_storage == 'inline' else None)
|
|
165
|
+ ]
|
|
166
|
+ }
|
|
167
|
+ element_name = 'test.bst'
|
|
168
|
+ element_path = os.path.join(element_dir, element_name)
|
|
169
|
+ full_repo = element['sources'][0]['url']
|
|
170
|
+ upstream_map, repo_name = os.path.split(full_repo)
|
|
171
|
+ alias = 'foo'
|
|
172
|
+ aliased_repo = alias + ':' + repo_name
|
|
173
|
+ element['sources'][0]['url'] = aliased_repo
|
|
174
|
+ full_mirror = mirror_repo.source_config()['url']
|
|
175
|
+ mirror_map, _ = os.path.split(full_mirror)
|
|
176
|
+ os.makedirs(element_dir)
|
|
177
|
+ _yaml.dump(element, element_path)
|
|
178
|
+
|
|
179
|
+ if ref_storage == 'project.refs':
|
|
180
|
+ # Manually set project.refs to avoid caching the repo prematurely
|
|
181
|
+ project_refs = {'projects': {
|
|
182
|
+ 'test': {
|
|
183
|
+ element_name: [
|
|
184
|
+ {'ref': upstream_ref}
|
|
185
|
+ ]
|
|
186
|
+ }
|
|
187
|
+ }}
|
|
188
|
+ project_refs_path = os.path.join(project_dir, 'project.refs')
|
|
189
|
+ _yaml.dump(project_refs, project_refs_path)
|
|
190
|
+
|
|
191
|
+ project = {
|
|
192
|
+ 'name': 'test',
|
|
193
|
+ 'element-path': 'elements',
|
|
194
|
+ 'aliases': {
|
|
195
|
+ alias: upstream_map + "/"
|
|
196
|
+ },
|
|
197
|
+ 'ref-storage': ref_storage
|
|
198
|
+ }
|
|
199
|
+ if mirror != 'no-mirror':
|
|
200
|
+ mirror_data = [{
|
|
201
|
+ 'name': 'middle-earth',
|
|
202
|
+ 'aliases': {alias: [mirror_map + '/']}
|
|
203
|
+ }]
|
|
204
|
+ if mirror == 'unrelated-mirror':
|
|
205
|
+ mirror_data.insert(0, {
|
|
206
|
+ 'name': 'narnia',
|
|
207
|
+ 'aliases': {'frob': ['http://www.example.com/repo']}
|
|
208
|
+ })
|
|
209
|
+ project['mirrors'] = mirror_data
|
|
210
|
+
|
|
211
|
+ project_file = os.path.join(project_dir, 'project.conf')
|
|
212
|
+ _yaml.dump(project, project_file)
|
|
213
|
+
|
|
214
|
+ result = cli.run(project=project_dir, args=['fetch', element_name])
|
|
215
|
+ result.assert_success()
|
|
216
|
+
|
|
217
|
+
|
142
|
218
|
@pytest.mark.datafiles(DATA_DIR)
|
143
|
219
|
@pytest.mark.parametrize("kind", [(kind) for kind in ALL_REPO_KINDS])
|
144
|
220
|
def test_mirror_fetch_upstream_absent(cli, tmpdir, datafiles, kind):
|