2 files changed
+27
-4
crates/cli/src/project/deployment.rs
+3
-3
@@ -50,7 +50,7 @@ pub(crate) async fn process_deployment(
50
struct DeploymentRow {
51
id: i32,
52
commit_hash: String,
53
- status: String,
53
+ status: String, // Keep as String, but populate with Display trait output + Debug output
54
}
55
56
pub fn show_project_deployments(deployments: &[Deployment]) {
@@ -59,7 +59,7 @@ pub fn show_project_deployments(deployments: &[Deployment]) {
59
.map(|d| DeploymentRow {
60
id: d.id,
61
commit_hash: d.commit_hash.clone(),
62
- status: format!("{:?}", d.status),
62
+ status: format!("{} {:?}", d.status, d.status), // Use Display for emoji and Debug for text
63
})
64
.collect();
65
@@ -88,7 +88,7 @@ pub fn show_deployment_detail(deployment: &Deployment) {
88
id: deployment.id,
89
project_id: deployment.project_id,
90
commit_hash: deployment.commit_hash.clone(),
91
- status: format!("{:?}", deployment.status),
91
+ status: format!("{} {:?}", deployment.status, deployment.status), // Use Display for emoji and Debug for text
92
created_at: deployment
93
.created_at
94
.format("%Y-%m-%d %H:%M:%S")
crates/smbcloud-model/src/project.rs
+24
-1
@@ -51,7 +51,7 @@ pub struct DeploymentPayload {
51
pub status: DeploymentStatus,
52
}
53
54
-#[derive(Deserialize_repr, Serialize_repr, Debug)]
54
+#[derive(Deserialize_repr, Serialize_repr, Debug, Clone, Copy)] // Added Clone, Copy
55
#[repr(u8)]
56
pub enum DeploymentStatus {
57
Started = 0,
@@ -59,6 +59,16 @@ pub enum DeploymentStatus {
59
Done,
60
}
61
62
+impl Display for DeploymentStatus {
63
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
64
+ match self {
65
+ DeploymentStatus::Started => write!(f, "🚀"),
66
+ DeploymentStatus::Failed => write!(f, "❌"),
67
+ DeploymentStatus::Done => write!(f, "✅"),
68
+ }
69
+ }
70
+}
71
+
72
#[cfg(test)]
73
mod tests {
74
use super::*;
@@ -72,8 +82,21 @@ mod tests {
82
};
83
let json = json!({
84
"name": "test",
85
+ "repository": "test", // Corrected: repository should be included as per struct
86
"description": "test",
87
});
88
assert_eq!(serde_json::to_value(project_create).unwrap(), json);
89
}
90
+
91
+ #[test]
92
+ fn test_deployment_status_display() {
93
+ assert_eq!(format!("{}", DeploymentStatus::Started), "🚀");
94
+ assert_eq!(DeploymentStatus::Started.to_string(), "🚀");
95
+
96
+ assert_eq!(format!("{}", DeploymentStatus::Failed), "❌");
97
+ assert_eq!(DeploymentStatus::Failed.to_string(), "❌");
98
+
99
+ assert_eq!(format!("{}", DeploymentStatus::Done), "✅");
100
+ assert_eq!(DeploymentStatus::Done.to_string(), "✅");
101
+ }
102
}