Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions lib/saluki-env/src/autodiscovery/providers/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ impl LocalAutodiscoveryProvider {

#[derive(Debug, Deserialize)]
struct LocalCheckConfig {
#[serde(default = "HashMap::new")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should just be able to do #[serde(default)] since HashMap<K, V> implements Default.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, thanks!

init_config: HashMap<String, serde_yaml::Value>,
instances: Vec<HashMap<String, serde_yaml::Value>>,
}
Expand Down Expand Up @@ -274,6 +275,16 @@ mod tests {
assert_eq!(config.source, "local");
}

#[tokio::test]
async fn test_parse_minimal_config_file() {
let test_file = test_data_path().join("test-minimal-config.yaml");

let (_, config) = parse_config_file(&test_file).await.unwrap();

// Parsing a config without `init_config` yields an empty hash map for that field.
assert!(config.init_config.value.is_empty());
}

#[tokio::test]
async fn test_scan_and_emit_events_new_config() {
let dir = tempdir().unwrap();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## This file is used for testing the parse_config_file function
## Minimal test configuration

instances:
-