sensors using keys
This commit is contained in:
@@ -23,7 +23,7 @@ use crate::repositories::runtime::{CreateRuntimeInput, RuntimeRepository};
|
||||
use crate::repositories::trigger::{
|
||||
CreateSensorInput, CreateTriggerInput, SensorRepository, TriggerRepository,
|
||||
};
|
||||
use crate::repositories::{Create, FindByRef};
|
||||
use crate::repositories::{Create, FindById, FindByRef, Update};
|
||||
|
||||
/// Result of loading pack components into the database.
|
||||
#[derive(Debug, Default)]
|
||||
@@ -514,6 +514,47 @@ impl<'a> PackComponentLoader<'a> {
|
||||
.unwrap_or("native");
|
||||
let (sensor_runtime_id, sensor_runtime_ref) = self.resolve_runtime(runner_type).await?;
|
||||
|
||||
// Validate: if the runner_type suggests an interpreted runtime (not native)
|
||||
// but we couldn't resolve it, or it resolved to a runtime with no
|
||||
// execution_config, warn at registration time rather than failing
|
||||
// opaquely at sensor startup with "Permission denied".
|
||||
let is_native_runner = matches!(
|
||||
runner_type.to_lowercase().as_str(),
|
||||
"native" | "builtin" | "standalone"
|
||||
);
|
||||
if sensor_runtime_id == 0 && !is_native_runner {
|
||||
let msg = format!(
|
||||
"Sensor '{}' declares runner_type '{}' but no matching runtime \
|
||||
was found in the database. The sensor will not be able to start. \
|
||||
Ensure the core pack (with runtimes) is loaded before registering \
|
||||
packs that depend on its runtimes.",
|
||||
filename, runner_type
|
||||
);
|
||||
warn!("{}", msg);
|
||||
result.warnings.push(msg);
|
||||
} else if sensor_runtime_id != 0 && !is_native_runner {
|
||||
// Verify the resolved runtime has a non-empty execution_config
|
||||
if let Some(runtime) =
|
||||
RuntimeRepository::find_by_id(self.pool, sensor_runtime_id).await?
|
||||
{
|
||||
let exec_config = runtime.parsed_execution_config();
|
||||
if exec_config.interpreter.binary.is_empty()
|
||||
|| exec_config.interpreter.binary == "native"
|
||||
|| exec_config.interpreter.binary == "none"
|
||||
{
|
||||
let msg = format!(
|
||||
"Sensor '{}' declares runner_type '{}' (resolved to runtime '{}') \
|
||||
but that runtime has no interpreter configured in its \
|
||||
execution_config. The sensor will fail to start. \
|
||||
Check the runtime definition for '{}'.",
|
||||
filename, runner_type, runtime.r#ref, runtime.r#ref
|
||||
);
|
||||
warn!("{}", msg);
|
||||
result.warnings.push(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let sensor_ref = match data.get("ref").and_then(|v| v.as_str()) {
|
||||
Some(r) => r.to_string(),
|
||||
None => {
|
||||
@@ -524,16 +565,6 @@ impl<'a> PackComponentLoader<'a> {
|
||||
}
|
||||
};
|
||||
|
||||
// Check if sensor already exists
|
||||
if let Some(existing) = SensorRepository::find_by_ref(self.pool, &sensor_ref).await? {
|
||||
info!(
|
||||
"Sensor '{}' already exists (ID: {}), skipping",
|
||||
sensor_ref, existing.id
|
||||
);
|
||||
result.sensors_skipped += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
let name = extract_name_from_ref(&sensor_ref);
|
||||
let label = data
|
||||
.get("label")
|
||||
@@ -570,6 +601,41 @@ impl<'a> PackComponentLoader<'a> {
|
||||
.and_then(|v| serde_json::to_value(v).ok())
|
||||
.unwrap_or_else(|| serde_json::json!({}));
|
||||
|
||||
// Upsert: update existing sensors so re-registration corrects
|
||||
// stale metadata (especially runtime assignments).
|
||||
if let Some(existing) = SensorRepository::find_by_ref(self.pool, &sensor_ref).await? {
|
||||
use crate::repositories::trigger::UpdateSensorInput;
|
||||
|
||||
let update_input = UpdateSensorInput {
|
||||
label: Some(label),
|
||||
description: Some(description),
|
||||
entrypoint: Some(entrypoint),
|
||||
runtime: Some(sensor_runtime_id),
|
||||
runtime_ref: Some(sensor_runtime_ref.clone()),
|
||||
trigger: Some(trigger_id.unwrap_or(existing.trigger)),
|
||||
trigger_ref: Some(trigger_ref.unwrap_or(existing.trigger_ref.clone())),
|
||||
enabled: Some(enabled),
|
||||
param_schema,
|
||||
config: Some(config),
|
||||
};
|
||||
|
||||
match SensorRepository::update(self.pool, existing.id, update_input).await {
|
||||
Ok(_) => {
|
||||
info!(
|
||||
"Updated sensor '{}' (ID: {}, runtime: {} → {})",
|
||||
sensor_ref, existing.id, existing.runtime_ref, sensor_runtime_ref
|
||||
);
|
||||
result.sensors_loaded += 1;
|
||||
}
|
||||
Err(e) => {
|
||||
let msg = format!("Failed to update sensor '{}': {}", sensor_ref, e);
|
||||
warn!("{}", msg);
|
||||
result.warnings.push(msg);
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
let input = CreateSensorInput {
|
||||
r#ref: sensor_ref.clone(),
|
||||
pack: Some(self.pack_id),
|
||||
|
||||
@@ -531,8 +531,13 @@ pub struct UpdateSensorInput {
|
||||
pub label: Option<String>,
|
||||
pub description: Option<String>,
|
||||
pub entrypoint: Option<String>,
|
||||
pub runtime: Option<Id>,
|
||||
pub runtime_ref: Option<String>,
|
||||
pub trigger: Option<Id>,
|
||||
pub trigger_ref: Option<String>,
|
||||
pub enabled: Option<bool>,
|
||||
pub param_schema: Option<JsonSchema>,
|
||||
pub config: Option<JsonValue>,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
@@ -688,6 +693,42 @@ impl Update for SensorRepository {
|
||||
has_updates = true;
|
||||
}
|
||||
|
||||
if let Some(runtime) = input.runtime {
|
||||
if has_updates {
|
||||
query.push(", ");
|
||||
}
|
||||
query.push("runtime = ");
|
||||
query.push_bind(runtime);
|
||||
has_updates = true;
|
||||
}
|
||||
|
||||
if let Some(runtime_ref) = &input.runtime_ref {
|
||||
if has_updates {
|
||||
query.push(", ");
|
||||
}
|
||||
query.push("runtime_ref = ");
|
||||
query.push_bind(runtime_ref);
|
||||
has_updates = true;
|
||||
}
|
||||
|
||||
if let Some(trigger) = input.trigger {
|
||||
if has_updates {
|
||||
query.push(", ");
|
||||
}
|
||||
query.push("trigger = ");
|
||||
query.push_bind(trigger);
|
||||
has_updates = true;
|
||||
}
|
||||
|
||||
if let Some(trigger_ref) = &input.trigger_ref {
|
||||
if has_updates {
|
||||
query.push(", ");
|
||||
}
|
||||
query.push("trigger_ref = ");
|
||||
query.push_bind(trigger_ref);
|
||||
has_updates = true;
|
||||
}
|
||||
|
||||
if let Some(param_schema) = &input.param_schema {
|
||||
if has_updates {
|
||||
query.push(", ");
|
||||
@@ -697,6 +738,15 @@ impl Update for SensorRepository {
|
||||
has_updates = true;
|
||||
}
|
||||
|
||||
if let Some(config) = &input.config {
|
||||
if has_updates {
|
||||
query.push(", ");
|
||||
}
|
||||
query.push("config = ");
|
||||
query.push_bind(config);
|
||||
has_updates = true;
|
||||
}
|
||||
|
||||
if !has_updates {
|
||||
// No updates requested, fetch and return existing entity
|
||||
return Self::get_by_id(executor, id).await;
|
||||
|
||||
@@ -34,14 +34,10 @@ async fn test_create_sensor_minimal() {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let runtime = RuntimeFixture::new_unique(
|
||||
Some(pack.id),
|
||||
Some(pack.r#ref.clone()),
|
||||
"python3",
|
||||
)
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
let runtime = RuntimeFixture::new_unique(Some(pack.id), Some(pack.r#ref.clone()), "python3")
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// Create sensor
|
||||
let sensor = SensorFixture::new_unique(
|
||||
@@ -85,14 +81,10 @@ async fn test_create_sensor_with_param_schema() {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let runtime = RuntimeFixture::new_unique(
|
||||
Some(pack.id),
|
||||
Some(pack.r#ref.clone()),
|
||||
"python3",
|
||||
)
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
let runtime = RuntimeFixture::new_unique(Some(pack.id), Some(pack.r#ref.clone()), "python3")
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let param_schema = json!({
|
||||
"type": "object",
|
||||
@@ -171,14 +163,10 @@ async fn test_create_sensor_duplicate_ref_fails() {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let runtime = RuntimeFixture::new_unique(
|
||||
Some(pack.id),
|
||||
Some(pack.r#ref.clone()),
|
||||
"python3",
|
||||
)
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
let runtime = RuntimeFixture::new_unique(Some(pack.id), Some(pack.r#ref.clone()), "python3")
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// Create first sensor
|
||||
let sensor_ref = format!("{}.duplicate_sensor", pack.r#ref);
|
||||
@@ -223,14 +211,10 @@ async fn test_create_sensor_invalid_ref_format_fails() {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let runtime = RuntimeFixture::new_unique(
|
||||
Some(pack.id),
|
||||
Some(pack.r#ref.clone()),
|
||||
"python3",
|
||||
)
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
let runtime = RuntimeFixture::new_unique(Some(pack.id), Some(pack.r#ref.clone()), "python3")
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// Try invalid ref formats
|
||||
let invalid_refs = vec![
|
||||
@@ -378,14 +362,10 @@ async fn test_find_by_id_exists() {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let runtime = RuntimeFixture::new_unique(
|
||||
Some(pack.id),
|
||||
Some(pack.r#ref.clone()),
|
||||
"python3",
|
||||
)
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
let runtime = RuntimeFixture::new_unique(Some(pack.id), Some(pack.r#ref.clone()), "python3")
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let sensor = SensorFixture::new_unique(
|
||||
Some(pack.id),
|
||||
@@ -433,14 +413,10 @@ async fn test_get_by_id_exists() {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let runtime = RuntimeFixture::new_unique(
|
||||
Some(pack.id),
|
||||
Some(pack.r#ref.clone()),
|
||||
"python3",
|
||||
)
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
let runtime = RuntimeFixture::new_unique(Some(pack.id), Some(pack.r#ref.clone()), "python3")
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let sensor = SensorFixture::new_unique(
|
||||
Some(pack.id),
|
||||
@@ -484,14 +460,10 @@ async fn test_find_by_ref_exists() {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let runtime = RuntimeFixture::new_unique(
|
||||
Some(pack.id),
|
||||
Some(pack.r#ref.clone()),
|
||||
"python3",
|
||||
)
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
let runtime = RuntimeFixture::new_unique(Some(pack.id), Some(pack.r#ref.clone()), "python3")
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let sensor = SensorFixture::new_unique(
|
||||
Some(pack.id),
|
||||
@@ -540,14 +512,10 @@ async fn test_get_by_ref_exists() {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let runtime = RuntimeFixture::new_unique(
|
||||
Some(pack.id),
|
||||
Some(pack.r#ref.clone()),
|
||||
"python3",
|
||||
)
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
let runtime = RuntimeFixture::new_unique(Some(pack.id), Some(pack.r#ref.clone()), "python3")
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let sensor = SensorFixture::new_unique(
|
||||
Some(pack.id),
|
||||
@@ -593,14 +561,10 @@ async fn test_list_all_sensors() {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let runtime = RuntimeFixture::new_unique(
|
||||
Some(pack.id),
|
||||
Some(pack.r#ref.clone()),
|
||||
"python3",
|
||||
)
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
let runtime = RuntimeFixture::new_unique(Some(pack.id), Some(pack.r#ref.clone()), "python3")
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// Create multiple sensors
|
||||
let _sensor1 = SensorFixture::new_unique(
|
||||
@@ -668,14 +632,10 @@ async fn test_update_label() {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let runtime = RuntimeFixture::new_unique(
|
||||
Some(pack.id),
|
||||
Some(pack.r#ref.clone()),
|
||||
"python3",
|
||||
)
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
let runtime = RuntimeFixture::new_unique(Some(pack.id), Some(pack.r#ref.clone()), "python3")
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let sensor = SensorFixture::new_unique(
|
||||
Some(pack.id),
|
||||
@@ -724,14 +684,10 @@ async fn test_update_description() {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let runtime = RuntimeFixture::new_unique(
|
||||
Some(pack.id),
|
||||
Some(pack.r#ref.clone()),
|
||||
"python3",
|
||||
)
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
let runtime = RuntimeFixture::new_unique(Some(pack.id), Some(pack.r#ref.clone()), "python3")
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let sensor = SensorFixture::new_unique(
|
||||
Some(pack.id),
|
||||
@@ -772,14 +728,10 @@ async fn test_update_entrypoint() {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let runtime = RuntimeFixture::new_unique(
|
||||
Some(pack.id),
|
||||
Some(pack.r#ref.clone()),
|
||||
"python3",
|
||||
)
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
let runtime = RuntimeFixture::new_unique(Some(pack.id), Some(pack.r#ref.clone()), "python3")
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let sensor = SensorFixture::new_unique(
|
||||
Some(pack.id),
|
||||
@@ -820,14 +772,10 @@ async fn test_update_enabled_status() {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let runtime = RuntimeFixture::new_unique(
|
||||
Some(pack.id),
|
||||
Some(pack.r#ref.clone()),
|
||||
"python3",
|
||||
)
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
let runtime = RuntimeFixture::new_unique(Some(pack.id), Some(pack.r#ref.clone()), "python3")
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let sensor = SensorFixture::new_unique(
|
||||
Some(pack.id),
|
||||
@@ -883,14 +831,10 @@ async fn test_update_param_schema() {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let runtime = RuntimeFixture::new_unique(
|
||||
Some(pack.id),
|
||||
Some(pack.r#ref.clone()),
|
||||
"python3",
|
||||
)
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
let runtime = RuntimeFixture::new_unique(Some(pack.id), Some(pack.r#ref.clone()), "python3")
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let sensor = SensorFixture::new_unique(
|
||||
Some(pack.id),
|
||||
@@ -941,14 +885,10 @@ async fn test_update_multiple_fields() {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let runtime = RuntimeFixture::new_unique(
|
||||
Some(pack.id),
|
||||
Some(pack.r#ref.clone()),
|
||||
"python3",
|
||||
)
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
let runtime = RuntimeFixture::new_unique(Some(pack.id), Some(pack.r#ref.clone()), "python3")
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let sensor = SensorFixture::new_unique(
|
||||
Some(pack.id),
|
||||
@@ -969,6 +909,7 @@ async fn test_update_multiple_fields() {
|
||||
entrypoint: Some("sensors/multi.py".to_string()),
|
||||
enabled: Some(false),
|
||||
param_schema: Some(json!({"type": "object"})),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let updated = SensorRepository::update(&pool, sensor.id, input)
|
||||
@@ -996,14 +937,10 @@ async fn test_update_no_changes() {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let runtime = RuntimeFixture::new_unique(
|
||||
Some(pack.id),
|
||||
Some(pack.r#ref.clone()),
|
||||
"python3",
|
||||
)
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
let runtime = RuntimeFixture::new_unique(Some(pack.id), Some(pack.r#ref.clone()), "python3")
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let sensor = SensorFixture::new_unique(
|
||||
Some(pack.id),
|
||||
@@ -1066,14 +1003,10 @@ async fn test_delete_existing_sensor() {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let runtime = RuntimeFixture::new_unique(
|
||||
Some(pack.id),
|
||||
Some(pack.r#ref.clone()),
|
||||
"python3",
|
||||
)
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
let runtime = RuntimeFixture::new_unique(Some(pack.id), Some(pack.r#ref.clone()), "python3")
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let sensor = SensorFixture::new_unique(
|
||||
Some(pack.id),
|
||||
@@ -1120,14 +1053,10 @@ async fn test_delete_sensor_when_pack_deleted() {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let runtime = RuntimeFixture::new_unique(
|
||||
Some(pack.id),
|
||||
Some(pack.r#ref.clone()),
|
||||
"python3",
|
||||
)
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
let runtime = RuntimeFixture::new_unique(Some(pack.id), Some(pack.r#ref.clone()), "python3")
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let sensor = SensorFixture::new_unique(
|
||||
Some(pack.id),
|
||||
@@ -1167,14 +1096,10 @@ async fn test_delete_sensor_when_trigger_deleted() {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let runtime = RuntimeFixture::new_unique(
|
||||
Some(pack.id),
|
||||
Some(pack.r#ref.clone()),
|
||||
"python3",
|
||||
)
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
let runtime = RuntimeFixture::new_unique(Some(pack.id), Some(pack.r#ref.clone()), "python3")
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let sensor = SensorFixture::new_unique(
|
||||
Some(pack.id),
|
||||
@@ -1214,14 +1139,10 @@ async fn test_delete_sensor_when_runtime_deleted() {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let runtime = RuntimeFixture::new_unique(
|
||||
Some(pack.id),
|
||||
Some(pack.r#ref.clone()),
|
||||
"python3",
|
||||
)
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
let runtime = RuntimeFixture::new_unique(Some(pack.id), Some(pack.r#ref.clone()), "python3")
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let sensor = SensorFixture::new_unique(
|
||||
Some(pack.id),
|
||||
@@ -1270,14 +1191,10 @@ async fn test_find_by_trigger() {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let runtime = RuntimeFixture::new_unique(
|
||||
Some(pack.id),
|
||||
Some(pack.r#ref.clone()),
|
||||
"python3",
|
||||
)
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
let runtime = RuntimeFixture::new_unique(Some(pack.id), Some(pack.r#ref.clone()), "python3")
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// Create sensors for trigger1
|
||||
let sensor1 = SensorFixture::new_unique(
|
||||
@@ -1364,14 +1281,10 @@ async fn test_find_enabled() {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let runtime = RuntimeFixture::new_unique(
|
||||
Some(pack.id),
|
||||
Some(pack.r#ref.clone()),
|
||||
"python3",
|
||||
)
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
let runtime = RuntimeFixture::new_unique(Some(pack.id), Some(pack.r#ref.clone()), "python3")
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// Create enabled sensor
|
||||
let enabled_sensor = SensorFixture::new_unique(
|
||||
@@ -1424,14 +1337,10 @@ async fn test_find_enabled_empty() {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let runtime = RuntimeFixture::new_unique(
|
||||
Some(pack.id),
|
||||
Some(pack.r#ref.clone()),
|
||||
"python3",
|
||||
)
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
let runtime = RuntimeFixture::new_unique(Some(pack.id), Some(pack.r#ref.clone()), "python3")
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// Create only disabled sensor
|
||||
let disabled = SensorFixture::new_unique(
|
||||
@@ -1477,23 +1386,15 @@ async fn test_find_by_pack() {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let runtime1 = RuntimeFixture::new_unique(
|
||||
Some(pack1.id),
|
||||
Some(pack1.r#ref.clone()),
|
||||
"python3",
|
||||
)
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
let runtime1 = RuntimeFixture::new_unique(Some(pack1.id), Some(pack1.r#ref.clone()), "python3")
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let runtime2 = RuntimeFixture::new_unique(
|
||||
Some(pack2.id),
|
||||
Some(pack2.r#ref.clone()),
|
||||
"nodejs",
|
||||
)
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
let runtime2 = RuntimeFixture::new_unique(Some(pack2.id), Some(pack2.r#ref.clone()), "nodejs")
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// Create sensors for pack1
|
||||
let sensor1 = SensorFixture::new_unique(
|
||||
@@ -1580,14 +1481,10 @@ async fn test_created_timestamp_set_automatically() {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let runtime = RuntimeFixture::new_unique(
|
||||
Some(pack.id),
|
||||
Some(pack.r#ref.clone()),
|
||||
"python3",
|
||||
)
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
let runtime = RuntimeFixture::new_unique(Some(pack.id), Some(pack.r#ref.clone()), "python3")
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let before = chrono::Utc::now();
|
||||
|
||||
@@ -1625,14 +1522,10 @@ async fn test_updated_timestamp_changes_on_update() {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let runtime = RuntimeFixture::new_unique(
|
||||
Some(pack.id),
|
||||
Some(pack.r#ref.clone()),
|
||||
"python3",
|
||||
)
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
let runtime = RuntimeFixture::new_unique(Some(pack.id), Some(pack.r#ref.clone()), "python3")
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let sensor = SensorFixture::new_unique(
|
||||
Some(pack.id),
|
||||
@@ -1679,14 +1572,10 @@ async fn test_updated_timestamp_unchanged_on_read() {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let runtime = RuntimeFixture::new_unique(
|
||||
Some(pack.id),
|
||||
Some(pack.r#ref.clone()),
|
||||
"python3",
|
||||
)
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
let runtime = RuntimeFixture::new_unique(Some(pack.id), Some(pack.r#ref.clone()), "python3")
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let sensor = SensorFixture::new_unique(
|
||||
Some(pack.id),
|
||||
@@ -1733,14 +1622,10 @@ async fn test_param_schema_complex_structure() {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let runtime = RuntimeFixture::new_unique(
|
||||
Some(pack.id),
|
||||
Some(pack.r#ref.clone()),
|
||||
"python3",
|
||||
)
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
let runtime = RuntimeFixture::new_unique(Some(pack.id), Some(pack.r#ref.clone()), "python3")
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let complex_schema = json!({
|
||||
"type": "object",
|
||||
@@ -1811,14 +1696,10 @@ async fn test_param_schema_can_be_null() {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let runtime = RuntimeFixture::new_unique(
|
||||
Some(pack.id),
|
||||
Some(pack.r#ref.clone()),
|
||||
"python3",
|
||||
)
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
let runtime = RuntimeFixture::new_unique(Some(pack.id), Some(pack.r#ref.clone()), "python3")
|
||||
.create(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let sensor = SensorFixture::new_unique(
|
||||
Some(pack.id),
|
||||
|
||||
Reference in New Issue
Block a user