use crate::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LicensesTemplateListEntry {
pub key: String,
pub name: String,
pub url: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LicenseTemplateInfo {
pub key: String,
pub name: String,
pub url: String,
pub body: String,
pub implementation: String,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_licenses_template_list_entry_round_trip() {
let original = LicensesTemplateListEntry {
key: "mit".to_string(),
name: "MIT".to_string(),
url: "https://example.com/licenses/mit".to_string(),
};
let json = serde_json::to_string(&original).unwrap();
let restored: LicensesTemplateListEntry = serde_json::from_str(&json).unwrap();
assert_eq!(restored.key, original.key);
assert_eq!(restored.name, original.name);
assert_eq!(restored.url, original.url);
}
#[test]
fn test_license_template_info_round_trip() {
let original = LicenseTemplateInfo {
key: "apache-2.0".to_string(),
name: "Apache License 2.0".to_string(),
url: "https://example.com/licenses/apache-2.0".to_string(),
body: "Apache License text".to_string(),
implementation: "Hashicorp".to_string(),
};
let json = serde_json::to_string(&original).unwrap();
let restored: LicenseTemplateInfo = serde_json::from_str(&json).unwrap();
assert_eq!(restored.key, original.key);
assert_eq!(restored.body, original.body);
assert_eq!(restored.implementation, original.implementation);
}
}