Skip to content

Commit 2a1ce44

Browse files
committed
tests: add overriding repo tests for Config.add_repo() support
1 parent aa3f29e commit 2a1ce44

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

tests/test_config.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def test_add_repo_path_fake(self, config, tmp_path):
7474
r = config.add_repo(f)
7575
assert len(r) == 3
7676

77-
def test_add_repo(self, config):
77+
def test_add_repo(self, config, make_ebuild_repo):
7878
assert not config.repos
7979
r1 = FakeRepo(id="r1", priority=1)
8080
r2 = FakeRepo(id="r2", priority=2)
@@ -86,6 +86,19 @@ def test_add_repo(self, config):
8686
# re-adding a repo succeeds
8787
assert r1 == config.add_repo(r1)
8888

89+
# overriding a repo fails
90+
r = FakeRepo(["cat/pkg-1"], id="r1")
91+
with pytest.raises(ConfigError, match="can't override existing repos: r1"):
92+
config.add_repo(r)
93+
94+
# external repos with matching names can be added since they're keyed via path
95+
r = make_ebuild_repo(id="r2")
96+
config.add_repo(r, external=True)
97+
98+
# but will fail if not added as an external repo
99+
with pytest.raises(ConfigError, match="can't override existing repos: r2"):
100+
config.add_repo(r, external=False)
101+
89102
def test_repo_sets(self, config, make_ebuild_repo, make_fake_repo):
90103
# empty
91104
assert config.repos.all == RepoSet()

0 commit comments

Comments
 (0)