about summary refs log tree commit diff
path: root/tvix/castore/src/proto/tests/mod.rs
blob: 9f6330914bff4742e4f126e7f1bb4bd9f727da56 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
use super::{node, Node, SymlinkNode};
use crate::DirectoryError;

mod directory;

/// Create a node with an empty symlink target, and ensure it fails validation.
#[test]
fn convert_symlink_empty_target_invalid() {
    Node {
        node: Some(node::Node::Symlink(SymlinkNode {
            name: "foo".into(),
            target: "".into(),
        })),
    }
    .try_into_name_and_node()
    .expect_err("must fail validation");
}

/// Create a node with a symlink target including null bytes, and ensure it
/// fails validation.
#[test]
fn convert_symlink_target_null_byte_invalid() {
    Node {
        node: Some(node::Node::Symlink(SymlinkNode {
            name: "foo".into(),
            target: "foo\0".into(),
        })),
    }
    .try_into_name_and_node()
    .expect_err("must fail validation");
}

/// Create a node with a name, and ensure our ano
#[test]
fn convert_anonymous_with_name_fail() {
    assert_eq!(
        DirectoryError::NameInAnonymousNode,
        Node {
            node: Some(node::Node::Symlink(SymlinkNode {
                name: "foo".into(),
                target: "somewhereelse".into(),
            })),
        }
        .try_into_anonymous_node()
        .expect_err("must fail")
    )
}