properly handling patch updates
Some checks failed
CI / Clippy (push) Failing after 3m6s
CI / Rustfmt (push) Failing after 3m9s
CI / Cargo Audit & Deny (push) Successful in 5m2s
CI / Tests (push) Successful in 8m15s
CI / Security Blocking Checks (push) Successful in 10s
CI / Web Advisory Checks (push) Successful in 1m4s
CI / Web Blocking Checks (push) Failing after 4m52s
Publish Images And Chart / Resolve Publish Metadata (push) Successful in 2s
CI / Security Advisory Checks (push) Successful in 1m31s
Publish Images And Chart / Publish init-user (push) Failing after 30s
Publish Images And Chart / Publish init-packs (push) Failing after 1m41s
Publish Images And Chart / Publish migrations (push) Failing after 10s
Publish Images And Chart / Publish web (push) Failing after 11s
Publish Images And Chart / Publish sensor (push) Failing after 32s
Publish Images And Chart / Publish worker (push) Failing after 11s
Publish Images And Chart / Publish executor (push) Failing after 11s
Publish Images And Chart / Publish notifier (push) Failing after 9s
Publish Images And Chart / Publish api (push) Failing after 31s
Publish Images And Chart / Publish Helm Chart (push) Has been skipped

This commit is contained in:
2026-03-17 12:17:58 -05:00
parent 643023b6d5
commit f96861d417
136 changed files with 3782 additions and 1553 deletions

View File

@@ -6,7 +6,9 @@
mod helpers;
use attune_common::repositories::pack::{self, PackRepository};
use attune_common::repositories::{Create, Delete, FindById, FindByRef, List, Pagination, Update};
use attune_common::repositories::{
Create, Delete, FindById, FindByRef, List, Pagination, Patch, Update,
};
use attune_common::Error;
use helpers::*;
use serde_json::json;
@@ -214,7 +216,7 @@ async fn test_update_pack() {
let update_input = pack::UpdatePackInput {
label: Some("Updated Label".to_string()),
version: Some("2.0.0".to_string()),
description: Some("Updated description".to_string()),
description: Some(Patch::Set("Updated description".to_string())),
..Default::default()
};

View File

@@ -9,7 +9,7 @@ use attune_common::models::enums::{
use attune_common::repositories::artifact::{
ArtifactRepository, CreateArtifactInput, UpdateArtifactInput,
};
use attune_common::repositories::{Create, Delete, FindById, FindByRef, List, Update};
use attune_common::repositories::{Create, Delete, FindById, FindByRef, List, Patch, Update};
use attune_common::Error;
use sqlx::PgPool;
use std::collections::hash_map::DefaultHasher;
@@ -267,11 +267,11 @@ async fn test_update_artifact_all_fields() {
visibility: Some(ArtifactVisibility::Public),
retention_policy: Some(RetentionPolicyType::Days),
retention_limit: Some(30),
name: Some("Updated Name".to_string()),
description: Some("Updated description".to_string()),
content_type: Some("image/png".to_string()),
name: Some(Patch::Set("Updated Name".to_string())),
description: Some(Patch::Set("Updated description".to_string())),
content_type: Some(Patch::Set("image/png".to_string())),
size_bytes: Some(12345),
data: Some(serde_json::json!({"key": "value"})),
data: Some(Patch::Set(serde_json::json!({"key": "value"}))),
execution: None,
};

View File

@@ -6,7 +6,7 @@
use attune_common::repositories::runtime::{
CreateRuntimeInput, RuntimeRepository, UpdateRuntimeInput,
};
use attune_common::repositories::{Create, Delete, FindById, FindByRef, List, Update};
use attune_common::repositories::{Create, Delete, FindById, FindByRef, List, Patch, Update};
use serde_json::json;
use sqlx::PgPool;
use std::collections::hash_map::DefaultHasher;
@@ -259,14 +259,14 @@ async fn test_update_runtime() {
.expect("Failed to create runtime");
let update_input = UpdateRuntimeInput {
description: Some("Updated description".to_string()),
description: Some(Patch::Set("Updated description".to_string())),
name: Some("updated_name".to_string()),
distributions: Some(json!({
"linux": { "supported": false }
})),
installation: Some(json!({
installation: Some(Patch::Set(json!({
"method": "npm"
})),
}))),
execution_config: None,
};
@@ -275,10 +275,10 @@ async fn test_update_runtime() {
.expect("Failed to update runtime");
assert_eq!(updated.id, created.id);
assert_eq!(updated.description, update_input.description);
assert_eq!(updated.description, Some("Updated description".to_string()));
assert_eq!(updated.name, update_input.name.unwrap());
assert_eq!(updated.distributions, update_input.distributions.unwrap());
assert_eq!(updated.installation, update_input.installation);
assert_eq!(updated.installation, Some(json!({ "method": "npm" })));
assert!(updated.updated > created.updated);
}
@@ -294,7 +294,7 @@ async fn test_update_runtime_partial() {
.expect("Failed to create runtime");
let update_input = UpdateRuntimeInput {
description: Some("Only description changed".to_string()),
description: Some(Patch::Set("Only description changed".to_string())),
name: None,
distributions: None,
installation: None,
@@ -305,7 +305,10 @@ async fn test_update_runtime_partial() {
.await
.expect("Failed to update runtime");
assert_eq!(updated.description, update_input.description);
assert_eq!(
updated.description,
Some("Only description changed".to_string())
);
assert_eq!(updated.name, created.name);
assert_eq!(updated.distributions, created.distributions);
assert_eq!(updated.installation, created.installation);
@@ -610,7 +613,7 @@ async fn test_update_changes_timestamp() {
tokio::time::sleep(tokio::time::Duration::from_millis(100)).await;
let update_input = UpdateRuntimeInput {
description: Some("Updated".to_string()),
description: Some(Patch::Set("Updated".to_string())),
..Default::default()
};

View File

@@ -8,7 +8,7 @@ mod helpers;
use attune_common::{
repositories::{
trigger::{CreateSensorInput, SensorRepository, UpdateSensorInput},
Create, Delete, FindById, FindByRef, List, Update,
Create, Delete, FindById, FindByRef, List, Patch, Update,
},
Error,
};
@@ -888,7 +888,7 @@ async fn test_update_param_schema() {
});
let input = UpdateSensorInput {
param_schema: Some(new_schema.clone()),
param_schema: Some(Patch::Set(new_schema.clone())),
..Default::default()
};
@@ -937,7 +937,7 @@ async fn test_update_multiple_fields() {
description: Some("Updated multiple fields".to_string()),
entrypoint: Some("sensors/multi.py".to_string()),
enabled: Some(false),
param_schema: Some(json!({"type": "object"})),
param_schema: Some(Patch::Set(json!({"type": "object"}))),
..Default::default()
};
@@ -1766,7 +1766,7 @@ async fn test_param_schema_can_be_null() {
// Update to add schema
let schema = json!({"type": "object"});
let input = UpdateSensorInput {
param_schema: Some(schema.clone()),
param_schema: Some(Patch::Set(schema.clone())),
..Default::default()
};

View File

@@ -8,7 +8,7 @@ mod helpers;
use attune_common::{
repositories::{
trigger::{CreateTriggerInput, TriggerRepository, UpdateTriggerInput},
Create, Delete, FindById, FindByRef, List, Update,
Create, Delete, FindById, FindByRef, List, Patch, Update,
},
Error,
};
@@ -477,7 +477,7 @@ async fn test_update_trigger() {
let update_input = UpdateTriggerInput {
label: Some("Updated Label".to_string()),
description: Some("Updated description".to_string()),
description: Some(Patch::Set("Updated description".to_string())),
enabled: Some(false),
param_schema: None,
out_schema: None,
@@ -571,8 +571,8 @@ async fn test_update_trigger_schemas() {
label: None,
description: None,
enabled: None,
param_schema: Some(new_param_schema.clone()),
out_schema: Some(new_out_schema.clone()),
param_schema: Some(Patch::Set(new_param_schema.clone())),
out_schema: Some(Patch::Set(new_out_schema.clone())),
};
let updated = TriggerRepository::update(&pool, trigger.id, update_input)