MCPcopy Create free account
hub / github.com/bufbuild/buf / createZipFromDir

Function createZipFromDir

cmd/buf/workspace_test.go:1713–1744  ·  view source on GitHub ↗
(t *testing.T, rootPath string, archiveName string)

Source from the content-addressed store, hash-verified

1711}
1712
1713func createZipFromDir(t *testing.T, rootPath string, archiveName string) string {
1714 zipDir := filepath.Join(t.TempDir(), rootPath)
1715 require.NoError(t, os.MkdirAll(zipDir, 0755))
1716
1717 storageosProvider := storageos.NewProvider(storageos.ProviderWithSymlinks())
1718 testdataBucket, err := storageosProvider.NewReadWriteBucket(
1719 rootPath,
1720 storageos.ReadWriteBucketWithSymlinksIfSupported(),
1721 )
1722 require.NoError(t, err)
1723
1724 buffer := bytes.NewBuffer(nil)
1725 require.NoError(t, storagearchive.Zip(
1726 t.Context(),
1727 testdataBucket,
1728 buffer,
1729 true,
1730 ))
1731
1732 zipBucket, err := storageosProvider.NewReadWriteBucket(
1733 zipDir,
1734 storageos.ReadWriteBucketWithSymlinksIfSupported(),
1735 )
1736 require.NoError(t, err)
1737 require.NoError(t, storage.PutPath(
1738 t.Context(),
1739 zipBucket,
1740 archiveName,
1741 buffer.Bytes(),
1742 ))
1743 return zipDir
1744}
1745
1746type expectedFileInfo struct {
1747 isImport bool

Calls 7

NewReadWriteBucketMethod · 0.95
NewProviderFunction · 0.92
ProviderWithSymlinksFunction · 0.92
ZipFunction · 0.92
PutPathFunction · 0.92
BytesMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…