oci_spec/distribution/
repository.rs

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
//! Repository types of the distribution spec.

use crate::error::OciSpecError;
use derive_builder::Builder;
use getset::{Getters, Setters};
use serde::{Deserialize, Serialize};

#[derive(Builder, Clone, Debug, Deserialize, Eq, Getters, Setters, PartialEq, Serialize)]
#[builder(
    pattern = "owned",
    setter(into, strip_option),
    build_fn(error = "OciSpecError")
)]
#[getset(get = "pub", set = "pub")]
/// RepositoryList returns a catalog of repositories maintained on the registry.
pub struct RepositoryList {
    /// The items of the RepositoryList.
    repositories: Vec<String>,
}

#[cfg(test)]
mod tests {
    use super::*;
    use crate::error::Result;

    #[test]
    fn repository_list_success() -> Result<()> {
        let list = RepositoryListBuilder::default()
            .repositories(vec![])
            .build()?;
        assert!(list.repositories().is_empty());
        Ok(())
    }

    #[test]
    fn repository_list_failure() {
        assert!(RepositoryListBuilder::default().build().is_err());
    }
}