diff mbox series

[v1,3/5] tests: fetch: add download test for the GitHub release artifact fetcher

Message ID 20250225070631.2262115-3-l.goehrs@pengutronix.de
State New
Headers show
Series [v1,1/5] fetch2/wget: enable classes derived from Wget to set custom http headers | expand

Commit Message

Leonard Göhrs Feb. 25, 2025, 7:06 a.m. UTC
The fetcher is mostly intended to work with release artifacts for
_private_ GitHub repositories, which require authentication in the form
of a token.

Release artifacts for public repositories can simply be downloaded using
the normal wget fetcher using a public and stable URL.

The tests use a public repository anyways because it would otherwise have
to contain a GitHub token that is supposed to be kept secret.

The `tslib` release referenced in the test is used because it is already
used by another test.

Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
---
 lib/bb/tests/fetch.py | 12 ++++++++++++
 1 file changed, 12 insertions(+)
diff mbox series

Patch

diff --git a/lib/bb/tests/fetch.py b/lib/bb/tests/fetch.py
index 48b9e4af1..6b23bae5b 100644
--- a/lib/bb/tests/fetch.py
+++ b/lib/bb/tests/fetch.py
@@ -1276,6 +1276,18 @@  class FetcherNetworkTest(FetcherTest):
             with self.assertRaises(bb.fetch2.FetchError):
                 fetcher.download()
 
+    @skipIfNoNetwork()
+    def test_github_release_artifact(self):
+        fetcher = bb.fetch.Fetch(["ghra://github.com/kergoth/tslib/1.1/tslib-1.1.tar.xz;sha256sum=fe35e5f710ea933b118f710e2ce4403ac076fe69926b570333867d4de082a51c"], self.d)
+        fetcher.download()
+        self.assertEqual(os.path.getsize(self.dldir + "/tslib-1.1.tar.xz"), 238184)
+        self.d.setVar("BB_NO_NETWORK", "1")
+        fetcher = bb.fetch.Fetch(["ghra://github.com/kergoth/tslib/1.1/tslib-1.1.tar.xz;sha256sum=fe35e5f710ea933b118f710e2ce4403ac076fe69926b570333867d4de082a51c"], self.d)
+        fetcher.download()
+        fetcher.unpack(self.unpackdir)
+        self.assertEqual(len(os.listdir(self.unpackdir + "/tslib-1.1/")), 29)
+
+
 class SVNTest(FetcherTest):
     def skipIfNoSvn():
         import shutil