diff mbox series

[2/2] tests: utils: add test for Go mod h1 checksum

Message ID 20250107151514.8115-3-stefan.herbrechtsmeier-oss@weidmueller.com
State Accepted, archived
Commit 3dc4d28a9eed962876c148dbe69d9f521bf42287
Headers show
Series Add Go mod h1 checksum support | expand

Commit Message

Stefan Herbrechtsmeier Jan. 7, 2025, 3:15 p.m. UTC
From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>

Add a basic test for the goh1_file function.

Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>

---

 lib/bb/tests/utils.py | 8 ++++++++
 1 file changed, 8 insertions(+)
diff mbox series

Patch

diff --git a/lib/bb/tests/utils.py b/lib/bb/tests/utils.py
index c363f62d7..48e61dfce 100644
--- a/lib/bb/tests/utils.py
+++ b/lib/bb/tests/utils.py
@@ -130,6 +130,14 @@  class Checksum(unittest.TestCase):
             checksum = bb.utils.sha256_file(f.name)
             self.assertEqual(checksum, "fcfbae8bf6b721dbb9d2dc6a9334a58f2031a9a9b302999243f99da4d7f12d0f")
 
+    def test_goh1(self):
+        import hashlib
+        with tempfile.NamedTemporaryFile() as f:
+            f.write(self.filler)
+            f.flush()
+            checksum = bb.utils.goh1_file(f.name)
+            self.assertEqual(checksum, "81191f04d4abf413e5badd234814e4202d9efa73e6f9437e9ddd6b8165b569ef")
+
 class EditMetadataFile(unittest.TestCase):
     _origfile = """
 # A comment