working on runtime executions
This commit is contained in:
@@ -874,6 +874,7 @@ pub struct RuntimeFixture {
|
||||
pub name: String,
|
||||
pub distributions: serde_json::Value,
|
||||
pub installation: Option<serde_json::Value>,
|
||||
pub execution_config: serde_json::Value,
|
||||
}
|
||||
|
||||
impl RuntimeFixture {
|
||||
@@ -896,6 +897,13 @@ impl RuntimeFixture {
|
||||
"darwin": { "supported": true }
|
||||
}),
|
||||
installation: None,
|
||||
execution_config: json!({
|
||||
"interpreter": {
|
||||
"binary": "/bin/bash",
|
||||
"args": [],
|
||||
"file_extension": ".sh"
|
||||
}
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -920,6 +928,13 @@ impl RuntimeFixture {
|
||||
"darwin": { "supported": true }
|
||||
}),
|
||||
installation: None,
|
||||
execution_config: json!({
|
||||
"interpreter": {
|
||||
"binary": "/bin/bash",
|
||||
"args": [],
|
||||
"file_extension": ".sh"
|
||||
}
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -947,6 +962,7 @@ impl RuntimeFixture {
|
||||
name: self.name,
|
||||
distributions: self.distributions,
|
||||
installation: self.installation,
|
||||
execution_config: self.execution_config,
|
||||
};
|
||||
|
||||
RuntimeRepository::create(pool, input).await
|
||||
|
||||
@@ -555,7 +555,6 @@ async fn test_enum_types_exist() {
|
||||
"notification_status_enum",
|
||||
"owner_type_enum",
|
||||
"policy_method_enum",
|
||||
"runtime_type_enum",
|
||||
"worker_status_enum",
|
||||
"worker_type_enum",
|
||||
];
|
||||
|
||||
@@ -72,6 +72,13 @@ impl RuntimeFixture {
|
||||
"method": "pip",
|
||||
"packages": ["requests", "pyyaml"]
|
||||
})),
|
||||
execution_config: json!({
|
||||
"interpreter": {
|
||||
"binary": "python3",
|
||||
"args": ["-u"],
|
||||
"file_extension": ".py"
|
||||
}
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,6 +95,13 @@ impl RuntimeFixture {
|
||||
name,
|
||||
distributions: json!({}),
|
||||
installation: None,
|
||||
execution_config: json!({
|
||||
"interpreter": {
|
||||
"binary": "/bin/bash",
|
||||
"args": [],
|
||||
"file_extension": ".sh"
|
||||
}
|
||||
}),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -245,6 +259,7 @@ async fn test_update_runtime() {
|
||||
installation: Some(json!({
|
||||
"method": "npm"
|
||||
})),
|
||||
execution_config: None,
|
||||
};
|
||||
|
||||
let updated = RuntimeRepository::update(&pool, created.id, update_input.clone())
|
||||
@@ -274,6 +289,7 @@ async fn test_update_runtime_partial() {
|
||||
name: None,
|
||||
distributions: None,
|
||||
installation: None,
|
||||
execution_config: None,
|
||||
};
|
||||
|
||||
let updated = RuntimeRepository::update(&pool, created.id, update_input.clone())
|
||||
@@ -428,16 +444,6 @@ async fn test_find_by_pack_empty() {
|
||||
assert_eq!(runtimes.len(), 0);
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Enum Tests
|
||||
// ============================================================================
|
||||
|
||||
// Test removed - runtime_type field no longer exists
|
||||
// #[tokio::test]
|
||||
// async fn test_runtime_type_enum() {
|
||||
// // runtime_type field removed from Runtime model
|
||||
// }
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_runtime_created_successfully() {
|
||||
let pool = setup_db().await;
|
||||
@@ -515,13 +521,13 @@ async fn test_list_ordering() {
|
||||
let fixture = RuntimeFixture::new("list_ordering");
|
||||
|
||||
let mut input1 = fixture.create_input("z_last");
|
||||
input1.r#ref = format!("{}.action.zzz", fixture.test_id);
|
||||
input1.r#ref = format!("{}.zzz", fixture.test_id);
|
||||
|
||||
let mut input2 = fixture.create_input("a_first");
|
||||
input2.r#ref = format!("{}.sensor.aaa", fixture.test_id);
|
||||
input2.r#ref = format!("{}.aaa", fixture.test_id);
|
||||
|
||||
let mut input3 = fixture.create_input("m_middle");
|
||||
input3.r#ref = format!("{}.action.mmm", fixture.test_id);
|
||||
input3.r#ref = format!("{}.mmm", fixture.test_id);
|
||||
|
||||
RuntimeRepository::create(&pool, input1)
|
||||
.await
|
||||
|
||||
@@ -550,13 +550,20 @@ async fn test_worker_with_runtime() {
|
||||
|
||||
// Create a runtime first
|
||||
let runtime_input = CreateRuntimeInput {
|
||||
r#ref: format!("{}.action.test_runtime", fixture.test_id),
|
||||
r#ref: format!("{}.test_runtime", fixture.test_id),
|
||||
pack: None,
|
||||
pack_ref: None,
|
||||
description: Some("Test runtime".to_string()),
|
||||
name: "test_runtime".to_string(),
|
||||
distributions: json!({}),
|
||||
installation: None,
|
||||
execution_config: json!({
|
||||
"interpreter": {
|
||||
"binary": "/bin/bash",
|
||||
"args": [],
|
||||
"file_extension": ".sh"
|
||||
}
|
||||
}),
|
||||
};
|
||||
|
||||
let runtime = RuntimeRepository::create(&pool, runtime_input)
|
||||
|
||||
@@ -66,9 +66,9 @@ async fn test_create_rule() {
|
||||
assert_eq!(rule.pack_ref, pack.r#ref);
|
||||
assert_eq!(rule.label, "Test Rule");
|
||||
assert_eq!(rule.description, "A test rule");
|
||||
assert_eq!(rule.action, action.id);
|
||||
assert_eq!(rule.action, Some(action.id));
|
||||
assert_eq!(rule.action_ref, action.r#ref);
|
||||
assert_eq!(rule.trigger, trigger.id);
|
||||
assert_eq!(rule.trigger, Some(trigger.id));
|
||||
assert_eq!(rule.trigger_ref, trigger.r#ref);
|
||||
assert_eq!(
|
||||
rule.conditions,
|
||||
@@ -1091,14 +1091,14 @@ async fn test_find_rules_by_action() {
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(action1_rules.len(), 2);
|
||||
assert!(action1_rules.iter().all(|r| r.action == action1.id));
|
||||
assert!(action1_rules.iter().all(|r| r.action == Some(action1.id)));
|
||||
|
||||
let action2_rules = RuleRepository::find_by_action(&pool, action2.id)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(action2_rules.len(), 1);
|
||||
assert_eq!(action2_rules[0].action, action2.id);
|
||||
assert_eq!(action2_rules[0].action, Some(action2.id));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
@@ -1172,14 +1172,14 @@ async fn test_find_rules_by_trigger() {
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(trigger1_rules.len(), 2);
|
||||
assert!(trigger1_rules.iter().all(|r| r.trigger == trigger1.id));
|
||||
assert!(trigger1_rules.iter().all(|r| r.trigger == Some(trigger1.id)));
|
||||
|
||||
let trigger2_rules = RuleRepository::find_by_trigger(&pool, trigger2.id)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(trigger2_rules.len(), 1);
|
||||
assert_eq!(trigger2_rules[0].trigger, trigger2.id);
|
||||
assert_eq!(trigger2_rules[0].trigger, Some(trigger2.id));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
||||
Reference in New Issue
Block a user