@@ -3439,3 +3439,59 @@ class DependencyTest(FetcherTest):
self.assertTrue(os.path.exists(os.path.join(self.unpackdir, "dummy/dummy.txt")))
self.assertTrue(os.path.exists(os.path.join(self.unpackdir, "dummy/bitbake-1.0")))
self.assertTrue(os.path.exists(os.path.join(self.unpackdir, "dummy/git")))
+
+class GoSumTest(FetcherTest):
+ def setUp(self):
+ super().setUp()
+ self.localsrcdir = os.path.join(self.tempdir, 'localsrc')
+ os.makedirs(self.localsrcdir)
+ self.d.setVar("FILESPATH", self.localsrcdir)
+
+ def create_go_sum_file(self, data):
+ filename = "go.sum"
+ with open(os.path.join(self.localsrcdir, filename), 'w') as f:
+ for module_path, version, hash in data:
+ f.write(f"{module_path} {version} {hash}\n")
+ return filename
+
+ @skipIfNoNetwork()
+ def test_gosum(self):
+ filename = self.create_go_sum_file([
+ (
+ "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob",
+ "v1.0.0",
+ "h1:u/LLAOFgsMv7HmNL4Qufg58y+qElGOt5qv0z1mURkRY="
+ ), (
+ "gopkg.in/ini.v1",
+ "v1.67.0/go.mod",
+ "h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k="
+ )
+ ])
+ fetcher = bb.fetch.Fetch(["gosum://" + filename], self.d)
+ fetcher.download()
+ self.assertTrue(os.path.exists(os.path.join(self.dldir, "github.com/!azure/azure-sdk-for-go/sdk/storage/azblob/@v/v1.0.0.zip")))
+ self.assertTrue(os.path.exists(os.path.join(self.dldir, "github.com/!azure/azure-sdk-for-go/sdk/storage/azblob/@v/v1.0.0.zip.done")))
+ self.assertTrue(os.path.exists(os.path.join(self.dldir, "gopkg.in/ini.v1/@v/v1.67.0.mod")))
+ self.assertTrue(os.path.exists(os.path.join(self.dldir, "gopkg.in/ini.v1/@v/v1.67.0.mod.done")))
+ fetcher.unpack(self.unpackdir)
+ self.assertTrue(os.path.exists(os.path.join(self.unpackdir, "go.sum")))
+ self.assertTrue(os.path.exists(os.path.join(self.unpackdir, "pkg/mod/cache/download/github.com/!azure/azure-sdk-for-go/sdk/storage/azblob/@v/v1.0.0.zip")))
+ self.assertTrue(os.path.exists(os.path.join(self.unpackdir, "pkg/mod/cache/download/github.com/!azure/azure-sdk-for-go/sdk/storage/azblob/@v/v1.0.0.mod")))
+ self.assertTrue(os.path.exists(os.path.join(self.unpackdir, "pkg/mod/cache/download/gopkg.in/ini.v1/@v/v1.67.0.mod")))
+
+ @skipIfNoNetwork()
+ def test_gosum_git(self):
+ urls = [
+ "gosum+git://github.com/Azure/azure-sdk-for-go.git;protocol=https;"
+ "nobranch=1;subpath=sdk/storage/azblob;"
+ "rev=ec928e0ed34db682b3f783d3739d1c538142e0c3"
+ ]
+ fetcher = bb.fetch.Fetch(urls, self.d)
+ fetcher.download()
+ self.assertTrue(os.path.exists(os.path.join(self.dldir, "git2/github.com.Azure.azure-sdk-for-go.git")))
+ self.assertTrue(os.path.exists(os.path.join(self.dldir, "golang.org/x/net/@v/v0.0.0-20220425223048-2871e0cb64e4.zip")))
+ self.assertTrue(os.path.exists(os.path.join(self.dldir, "golang.org/x/net/@v/v0.0.0-20220425223048-2871e0cb64e4.zip.done")))
+ fetcher.unpack(self.unpackdir)
+ self.assertTrue(os.path.exists(os.path.join(self.unpackdir, "azblob/go.sum")))
+ self.assertTrue(os.path.exists(os.path.join(self.unpackdir, "azblob/pkg/mod/cache/download/golang.org/x/net/@v/v0.0.0-20220425223048-2871e0cb64e4.zip")))
+ self.assertTrue(os.path.exists(os.path.join(self.unpackdir, "azblob/pkg/mod/cache/download/golang.org/x/net/@v/v0.0.0-20220425223048-2871e0cb64e4.mod")))