Coverage Report

Created: 2024-02-20 21:15

/builds/xfbs/cindy/common/src/api/tests.rs
Line
Count
Source
1
use super::*;
2
use crate::hash::Hash;
3
use restless::*;
4
use std::path::Path;
5
6
trait IntoUri {
7
    fn uri(&self) -> String;
8
}
9
10
impl<T: GetRequest> IntoUri for T {
11
4
    fn uri(&self) -> String {
12
4
        restless::methods::Get::from(self).uri()
13
4
    }
14
}
15
16
1
#[test]
17
1
fn test_uri() {
18
1
    let pairs: &[(&dyn IntoUri, &str)] = &[
19
1
        (
20
1
            &FrontendFile {
21
1
                path: Path::new("index.html"),
22
1
            },
23
1
            "index.html",
24
1
        ),
25
1
        (&TagNames, "api/v1/tags"),
26
1
        (
27
1
            &FileContent {
28
1
                hash: Hash::new(&[0xab]),
29
1
            },
30
1
            "api/v1/file/ab",
31
1
        ),
32
1
        (
33
1
            &FileTags {
34
1
                hash: Hash::new(&[0xab]),
35
1
                name: None::<&str>,
36
1
                value: None::<&str>,
37
1
            },
38
1
            "api/v1/file/ab/tags",
39
1
        ),
40
1
    ];
41
42
5
    for (
request, uri4
) in pairs {
43
4
        assert_eq!(&request.uri(), uri);
44
    }
45
1
}