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
//! Tag 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")]
/// A list of tags for a given repository.
pub struct TagList {
    /// The namespace of the repository.
    name: String,

    /// Each tags on the repository.
    tags: Vec<String>,
}

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

    #[test]
    fn tag_list_success() -> Result<()> {
        let list = TagListBuilder::default()
            .name("name")
            .tags(vec![])
            .build()?;
        assert!(list.tags().is_empty());
        assert_eq!(list.name(), "name");
        Ok(())
    }

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