diff options
author | Florian Klink <flokli@flokli.de> | 2023-10-10T19·24+0200 |
---|---|---|
committer | flokli <flokli@flokli.de> | 2023-10-10T20·22+0000 |
commit | d94749ac220cb8f35d063a02579b9eadf73b5cf2 (patch) | |
tree | a171a3155bde63421f9bddc45beb668d509fa103 /tvix/store/protos/export_test.go | |
parent | fe963ae0a3f5254023a55e3d0bca318953c9af12 (diff) |
refactor(tvix/store/protos): have Export accept root node r/6774
We don't need the full PathInfo message, only the root node. Change-Id: I667045ed766875dfbf8ac126a50b02baa2df67a4 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9604 Tested-by: BuildkiteCI Reviewed-by: edef <edef@edef.eu>
Diffstat (limited to 'tvix/store/protos/export_test.go')
-rw-r--r-- | tvix/store/protos/export_test.go | 49 |
1 files changed, 21 insertions, 28 deletions
diff --git a/tvix/store/protos/export_test.go b/tvix/store/protos/export_test.go index d45dd1ee7cf3..9b1901758f83 100644 --- a/tvix/store/protos/export_test.go +++ b/tvix/store/protos/export_test.go @@ -30,21 +30,18 @@ func mustBlobDigest(r io.Reader) []byte { } func TestSymlink(t *testing.T) { - pathInfo := &storev1pb.PathInfo{ - - Node: &castorev1pb.Node{ - Node: &castorev1pb.Node_Symlink{ - Symlink: &castorev1pb.SymlinkNode{ - Name: []byte("doesntmatter"), - Target: []byte("/nix/store/somewhereelse"), - }, + node := &castorev1pb.Node{ + Node: &castorev1pb.Node_Symlink{ + Symlink: &castorev1pb.SymlinkNode{ + Name: []byte("doesntmatter"), + Target: []byte("/nix/store/somewhereelse"), }, }, } var buf bytes.Buffer - err := storev1pb.Export(&buf, pathInfo, func([]byte) (*castorev1pb.Directory, error) { + err := storev1pb.Export(&buf, node, func([]byte) (*castorev1pb.Directory, error) { panic("no directories expected") }, func([]byte) (io.ReadCloser, error) { panic("no files expected") @@ -70,22 +67,20 @@ func TestRegular(t *testing.T) { 0x65, 0x2b, } - pathInfo := &storev1pb.PathInfo{ - Node: &castorev1pb.Node{ - Node: &castorev1pb.Node_File{ - File: &castorev1pb.FileNode{ - Name: []byte("doesntmatter"), - Digest: BLAKE3_DIGEST_0X01, - Size: 1, - Executable: false, - }, + node := &castorev1pb.Node{ + Node: &castorev1pb.Node_File{ + File: &castorev1pb.FileNode{ + Name: []byte("doesntmatter"), + Digest: BLAKE3_DIGEST_0X01, + Size: 1, + Executable: false, }, }, } var buf bytes.Buffer - err := storev1pb.Export(&buf, pathInfo, func([]byte) (*castorev1pb.Directory, error) { + err := storev1pb.Export(&buf, node, func([]byte) (*castorev1pb.Directory, error) { panic("no directories expected") }, func(blobRef []byte) (io.ReadCloser, error) { if !bytes.Equal(blobRef, BLAKE3_DIGEST_0X01) { @@ -115,21 +110,19 @@ func TestEmptyDirectory(t *testing.T) { } emptyDirectoryDigest := mustDirectoryDigest(emptyDirectory) - pathInfo := &storev1pb.PathInfo{ - Node: &castorev1pb.Node{ - Node: &castorev1pb.Node_Directory{ - Directory: &castorev1pb.DirectoryNode{ - Name: []byte("doesntmatter"), - Digest: emptyDirectoryDigest, - Size: 0, - }, + node := &castorev1pb.Node{ + Node: &castorev1pb.Node_Directory{ + Directory: &castorev1pb.DirectoryNode{ + Name: []byte("doesntmatter"), + Digest: emptyDirectoryDigest, + Size: 0, }, }, } var buf bytes.Buffer - err := storev1pb.Export(&buf, pathInfo, func(directoryRef []byte) (*castorev1pb.Directory, error) { + err := storev1pb.Export(&buf, node, func(directoryRef []byte) (*castorev1pb.Directory, error) { if !bytes.Equal(directoryRef, emptyDirectoryDigest) { panic("unexpected directoryRef") } |