Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Builder::from_manifest_def #544

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions sdk/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,13 @@ impl AsRef<Builder> for Builder {
}

impl Builder {
pub fn from_manifest_def(manifest_def: ManifestDefinition) -> Self {
Self {
definition: manifest_def,
..Default::default()
}
}

/// Creates a new builder from a JSON [`ManifestDefinition`] string.
///
/// # Arguments
Expand Down Expand Up @@ -976,6 +983,22 @@ mod tests {
);
}

#[test]
fn test_from_manifest_def() {
let manifest_def = ManifestDefinition {
vendor: Some("test".to_string()),
title: Some("Test_Manifest".to_string()),
format: "image/tiff".to_string(),
instance_id: "1234".to_string(),
..Default::default()
};
let builder = Builder::from_manifest_def(manifest_def);
assert_eq!(builder.definition.vendor, Some("test".to_string()));
assert_eq!(builder.definition.title, Some("Test_Manifest".to_string()));
assert_eq!(builder.definition.format, "image/tiff".to_string());
assert_eq!(builder.definition.instance_id, "1234".to_string());
}

#[test]
fn test_from_json() {
// strip whitespace so we can compare later
Expand Down
Loading