use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ProjectItem {
pub name: String,
pub slug: String,
pub id: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ProjectsListResponse {
pub projects: Vec<ProjectItem>,
#[serde(rename = "hasNextPage")]
pub has_next_page: bool,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_project_item_serialization() {
let item = ProjectItem {
name: "My Project".to_string(),
slug: "my-project".to_string(),
id: "proj-123".to_string(),
};
let json = serde_json::to_string(&item).unwrap();
assert!(json.contains("My Project"));
assert!(json.contains("my-project"));
assert!(json.contains("proj-123"));
}
#[test]
fn test_projects_list_response_deserialization() {
let json = r#"{
"projects": [
{
"name": "Test",
"slug": "test",
"id": "123"
}
],
"hasNextPage": false
}"#;
let response: ProjectsListResponse = serde_json::from_str(json).unwrap();
assert_eq!(response.projects.len(), 1);
assert!(!response.has_next_page);
}
}