Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7123213
D3436.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
D3436.diff
View Options
diff --git a/swh/loader/package/nixguix/loader.py b/swh/loader/package/nixguix/loader.py
--- a/swh/loader/package/nixguix/loader.py
+++ b/swh/loader/package/nixguix/loader.py
@@ -196,7 +196,8 @@
)
# Only the version 1 is currently supported
- if sources["version"] != 1:
+ version = int(sources["version"])
+ if version != 1:
raise ValueError(
"The sources structure version '%d' is not supported", sources["version"]
)
diff --git a/swh/loader/package/nixguix/tests/data/https_nix-community.github.io/nixpkgs-swh_sources.json b/swh/loader/package/nixguix/tests/data/https_nix-community.github.io/nixpkgs-swh_sources.json
--- a/swh/loader/package/nixguix/tests/data/https_nix-community.github.io/nixpkgs-swh_sources.json
+++ b/swh/loader/package/nixguix/tests/data/https_nix-community.github.io/nixpkgs-swh_sources.json
@@ -11,6 +11,6 @@
"integrity": "sha256-Q0copBCnj1b8G1iZw1k0NuYasMcx6QctleltspAgXlM="
}
],
- "version": 1,
+ "version": "1",
"revision": "cc4e04c26672dd74e5fd0fecb78b435fb55368f7"
}
diff --git a/swh/loader/package/nixguix/tests/test_nixguix.py b/swh/loader/package/nixguix/tests/test_nixguix.py
--- a/swh/loader/package/nixguix/tests/test_nixguix.py
+++ b/swh/loader/package/nixguix/tests/test_nixguix.py
@@ -59,12 +59,16 @@
def test_clean_sources_invalid_version(swh_config, requests_mock_datadir):
- sources = {"version": 2, "sources": [], "revision": "my-revision"}
-
- with pytest.raises(
- ValueError, match="sources structure version .* is not supported"
- ):
- clean_sources(sources)
+ for version_ok in [1, "1"]: # Check those versions are fine
+ clean_sources({"version": version_ok, "sources": [], "revision": "my-revision"})
+
+ for version_ko in [0, "0", 2, "2"]: # Check version != 1 raise an error
+ with pytest.raises(
+ ValueError, match="sources structure version .* is not supported"
+ ):
+ clean_sources(
+ {"version": version_ko, "sources": [], "revision": "my-revision"}
+ )
def test_clean_sources_invalid_sources(swh_config, requests_mock_datadir):
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Dec 18, 3:13 AM (2 d, 3 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3216464
Attached To
D3436: nixguix/loader: Allow version both as string or integer
Event Timeline
Log In to Comment