use crate::identity::ArtifactId;
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct Artifact {
id: ArtifactId,
}
impl Artifact {
pub fn new(id: ArtifactId) -> Self {
Self { id }
}
pub fn id(&self) -> &ArtifactId {
&self.id
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::identity::ArtifactId;
#[test]
fn artifact_wraps_artifact_id() {
let id = ArtifactId::new("test-artifact").unwrap();
let artifact = Artifact::new(id.clone());
assert_eq!(artifact.id(), &id);
}
#[test]
fn artifact_preserves_stable_identity() {
let id = ArtifactId::new("stable-id").unwrap();
let first = Artifact::new(id.clone());
let second = Artifact::new(id.clone());
assert_eq!(first, second);
assert_eq!(first.id(), second.id());
}
#[test]
fn artifact_supports_clone_and_eq() {
let id = ArtifactId::new("clone-test").unwrap();
let artifact = Artifact::new(id);
assert_eq!(artifact.clone(), artifact);
}
}