about summary refs log tree commit diff
path: root/tvix/castore/protos/castore_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/castore/protos/castore_test.go')
-rw-r--r--tvix/castore/protos/castore_test.go37
1 files changed, 32 insertions, 5 deletions
diff --git a/tvix/castore/protos/castore_test.go b/tvix/castore/protos/castore_test.go
index 958d399d76cc..fda87a6cfb66 100644
--- a/tvix/castore/protos/castore_test.go
+++ b/tvix/castore/protos/castore_test.go
@@ -122,7 +122,7 @@ func TestDirectoryValidate(t *testing.T) {
 				Symlinks: []*castorev1pb.SymlinkNode{},
 			}
 
-			assert.ErrorContains(t, d.Validate(), "invalid name")
+			assert.ErrorContains(t, d.Validate(), "invalid node name")
 		}
 		{
 			d := castorev1pb.Directory{
@@ -135,7 +135,7 @@ func TestDirectoryValidate(t *testing.T) {
 				Symlinks: []*castorev1pb.SymlinkNode{},
 			}
 
-			assert.ErrorContains(t, d.Validate(), "invalid name")
+			assert.ErrorContains(t, d.Validate(), "invalid node name")
 		}
 		{
 			d := castorev1pb.Directory{
@@ -149,7 +149,7 @@ func TestDirectoryValidate(t *testing.T) {
 				Symlinks: []*castorev1pb.SymlinkNode{},
 			}
 
-			assert.ErrorContains(t, d.Validate(), "invalid name")
+			assert.ErrorContains(t, d.Validate(), "invalid node name")
 		}
 		{
 			d := castorev1pb.Directory{
@@ -161,7 +161,7 @@ func TestDirectoryValidate(t *testing.T) {
 				}},
 			}
 
-			assert.ErrorContains(t, d.Validate(), "invalid name")
+			assert.ErrorContains(t, d.Validate(), "invalid node name")
 		}
 		{
 			d := castorev1pb.Directory{
@@ -173,7 +173,7 @@ func TestDirectoryValidate(t *testing.T) {
 				}},
 			}
 
-			assert.ErrorContains(t, d.Validate(), "invalid name")
+			assert.ErrorContains(t, d.Validate(), "invalid node name")
 		}
 	})
 
@@ -191,6 +191,33 @@ func TestDirectoryValidate(t *testing.T) {
 		assert.ErrorContains(t, d.Validate(), "invalid digest length")
 	})
 
+	t.Run("invalid symlink targets", func(t *testing.T) {
+		{
+			d := castorev1pb.Directory{
+				Directories: []*castorev1pb.DirectoryNode{},
+				Files:       []*castorev1pb.FileNode{},
+				Symlinks: []*castorev1pb.SymlinkNode{{
+					Name:   []byte("foo"),
+					Target: []byte{},
+				}},
+			}
+
+			assert.ErrorContains(t, d.Validate(), "invalid symlink target")
+		}
+		{
+			d := castorev1pb.Directory{
+				Directories: []*castorev1pb.DirectoryNode{},
+				Files:       []*castorev1pb.FileNode{},
+				Symlinks: []*castorev1pb.SymlinkNode{{
+					Name:   []byte("foo"),
+					Target: []byte{0x66, 0x6f, 0x6f, 0},
+				}},
+			}
+
+			assert.ErrorContains(t, d.Validate(), "invalid symlink target")
+		}
+	})
+
 	t.Run("sorting", func(t *testing.T) {
 		// "b" comes before "a", bad.
 		{