diff mbox series

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

Message ID 20250307120055.1816436-4-l.goehrs@pengutronix.de
State New
Headers show
Series fetch2/github_release_artifact: fetcher for (private) release artifacts | expand

Commit Message

Leonard Göhrs March 7, 2025, noon 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 c19180aaf..517894881 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