Skip to content

Commit

Permalink
Merge pull request #224 from rruckley/bug-tmf620-hasdescription-221
Browse files Browse the repository at this point in the history
Bug: Implemented TMF620 HasDescription
  • Loading branch information
rruckley authored Jan 22, 2025
2 parents 258d08d + 570df83 commit a060b18
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ allow_dirty = true

[package]
name = "tmflib"
version = "0.1.25"
version = "0.1.26"
edition = "2021"
authors = ["Ryan Ruckley <[email protected]>"]
description = "Interface library for processing TMF payloads"
Expand Down Expand Up @@ -216,10 +216,10 @@ default = ["all","build-V4"]
chrono = "0.4.39"
rust_iso4217 = "0.1.1"
serde = { version = "1.0.217", features = ["derive"]}
serde_json = "1.0.135"
serde_json = "1.0.137"
sha256 = { version = "1.5", default-features = false }
uuid = { version = "1.11.0", features = ["v4"]}
tmflib-derive = { version = "0.1.29" }
uuid = { version = "1.12.1", features = ["v4"]}
tmflib-derive = { version = "0.1.30" }
# tmflib-derive = { path = "tmflib-derive"}
hex = "0.4.3"
base32 = "0.5.1"
Expand Down
24 changes: 21 additions & 3 deletions src/tmf620/catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use crate::{
HasId,
HasName,
HasDescription,
HasLastUpdate,
HasValidity,
HasRelatedParty,
Expand All @@ -16,7 +17,14 @@ use crate::{
use crate::tmf620::category::CategoryRef;
use crate::common::related_party::RelatedParty;
use crate::common::event::{Event,EventPayload};
use tmflib_derive::{HasLastUpdate,HasId,HasName,HasValidity,HasRelatedParty};
use tmflib_derive::{
HasLastUpdate,
HasId,
HasName,
HasDescription,
HasValidity,
HasRelatedParty
};

use chrono::Utc;
use serde::{Deserialize, Serialize};
Expand All @@ -29,7 +37,7 @@ const CLASS_PATH: &str = "catalog";
const CAT_VERS: &str = "1.0";

/// Catalogue
#[derive(Clone, Default, Debug, Deserialize,HasLastUpdate, HasId, HasName, HasValidity, HasRelatedParty, Serialize)]
#[derive(Clone, Default, Debug, Deserialize,HasLastUpdate, HasId, HasName, HasDescription, HasValidity, HasRelatedParty, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Catalog {
/// Non-optional fields
Expand Down Expand Up @@ -194,6 +202,7 @@ pub struct CatalogBatchEvent {}
mod tests {

const CAT_NAME : &str = "A Catalog";
const CAT_DESC : &str = "A Description";

use crate::common::event::EventPayload;
use crate::common::related_party::RelatedParty;
Expand All @@ -202,7 +211,7 @@ mod tests {

use super::{Catalog, CatalogEvent, CatalogEventType};
use crate::tmf620::category::{Category, CategoryRef};
use crate::{HasId,HasName, HasValidity,HasRelatedParty,TimePeriod};
use crate::{HasDescription, HasId, HasName, HasRelatedParty, HasValidity, TimePeriod};

const CAT_JSON : &str = "{
\"name\" : \"CatalogueName\",
Expand Down Expand Up @@ -345,5 +354,14 @@ mod tests {
assert_eq!(related_party.name,Some("An Organisation".to_string()));
}

#[test]
fn test_catalog_description() {
let cat = Catalog::new(CAT_NAME)
.description(CAT_DESC);

assert_eq!(cat.description.is_some(),true);
assert_eq!(cat.get_description(),CAT_DESC.to_string());
}


}

0 comments on commit a060b18

Please sign in to comment.