Skip to content

Commit a656b4a

Browse files
committed
refacto: remove tests that checks there is no regression in configuration
1 parent 0c16838 commit a656b4a

File tree

4 files changed

+0
-499
lines changed

4 files changed

+0
-499
lines changed

mithril-aggregator/src/commands/mod.rs

-66
Original file line numberDiff line numberDiff line change
@@ -142,69 +142,3 @@ impl MainOpts {
142142
}
143143
}
144144
}
145-
146-
#[cfg(test)]
147-
mod tests {
148-
use config::ValueKind;
149-
150-
use crate::commands::tools_command::{
151-
RecomputeCertificatesHashCommand, ToolsCommand, ToolsSubCommand::RecomputeCertificatesHash,
152-
};
153-
154-
use super::*;
155-
156-
// TODO : just here to check there is no regression with the old configuration.
157-
// We may remove it and probably all tests in this file when macros are finished
158-
impl MainOpts {
159-
fn collect_legacy(&self) -> Result<Map<String, Value>, config::ConfigError> {
160-
let mut result = Map::new();
161-
let namespace = "clap arguments".to_string();
162-
163-
if let Some(db_directory) = self.db_directory.clone() {
164-
result.insert(
165-
"db_directory".to_string(),
166-
Value::new(
167-
Some(&namespace),
168-
ValueKind::from(format!("{}", db_directory.to_string_lossy())),
169-
),
170-
);
171-
}
172-
173-
Ok(result)
174-
}
175-
}
176-
177-
#[test]
178-
fn test_main_opts_collect() {
179-
let serve_command = MainOpts {
180-
db_directory: Some(PathBuf::from("/db_directory")),
181-
command: MainCommand::Tools(ToolsCommand {
182-
genesis_subcommand: RecomputeCertificatesHash(RecomputeCertificatesHashCommand {}),
183-
}),
184-
run_mode: "mode".to_string(),
185-
verbose: 1,
186-
config_directory: PathBuf::from(""),
187-
};
188-
189-
let result = serve_command.collect().unwrap().clone();
190-
191-
assert_eq!(serve_command.collect_legacy().unwrap(), result);
192-
}
193-
194-
#[test]
195-
fn test_main_opts_collect_when_empty_values() {
196-
let serve_command = MainOpts {
197-
db_directory: None,
198-
command: MainCommand::Tools(ToolsCommand {
199-
genesis_subcommand: RecomputeCertificatesHash(RecomputeCertificatesHashCommand {}),
200-
}),
201-
run_mode: "mode".to_string(),
202-
verbose: 1,
203-
config_directory: PathBuf::from(""),
204-
};
205-
206-
let result = serve_command.collect().unwrap().clone();
207-
208-
assert_eq!(serve_command.collect_legacy().unwrap(), result);
209-
}
210-
}

mithril-aggregator/src/commands/serve_command.rs

-190
Original file line numberDiff line numberDiff line change
@@ -322,193 +322,3 @@ impl ServeCommand {
322322
Ok(())
323323
}
324324
}
325-
326-
#[cfg(test)]
327-
mod tests {
328-
use config::ValueKind;
329-
330-
use super::*;
331-
use std::collections::HashMap;
332-
333-
// TODO : just here to check there is no regression with the old configuration.
334-
// We may remove it and probably all tests in this file when macros are finished
335-
impl ServeCommand {
336-
fn collect_legacy(&self) -> Result<Map<String, Value>, config::ConfigError> {
337-
let mut result = Map::new();
338-
let namespace = "clap arguments".to_string();
339-
340-
if let Some(server_ip) = self.server_ip.clone() {
341-
result.insert(
342-
"server_ip".to_string(),
343-
Value::new(Some(&namespace), ValueKind::from(server_ip)),
344-
);
345-
}
346-
if let Some(server_port) = self.server_port {
347-
result.insert(
348-
"server_port".to_string(),
349-
Value::new(Some(&namespace), ValueKind::from(server_port)),
350-
);
351-
}
352-
if let Some(snapshot_directory) = self.snapshot_directory.clone() {
353-
result.insert(
354-
"snapshot_directory".to_string(),
355-
Value::new(
356-
Some(&namespace),
357-
ValueKind::from(format!("{}", snapshot_directory.to_string_lossy())),
358-
),
359-
);
360-
}
361-
if self.disable_digests_cache {
362-
result.insert(
363-
"disable_digests_cache".to_string(),
364-
Value::new(Some(&namespace), ValueKind::from(true)),
365-
);
366-
};
367-
if self.reset_digests_cache {
368-
result.insert(
369-
"reset_digests_cache".to_string(),
370-
Value::new(Some(&namespace), ValueKind::from(true)),
371-
);
372-
}
373-
if self.allow_unparsable_block {
374-
result.insert(
375-
"allow_unparsable_block".to_string(),
376-
Value::new(Some(&namespace), ValueKind::from(true)),
377-
);
378-
};
379-
if self.enable_metrics_server {
380-
result.insert(
381-
"enable_metrics_server".to_string(),
382-
Value::new(Some(&namespace), ValueKind::from(true)),
383-
);
384-
};
385-
if let Some(metrics_server_ip) = self.metrics_server_ip.clone() {
386-
result.insert(
387-
"metrics_server_ip".to_string(),
388-
Value::new(Some(&namespace), ValueKind::from(metrics_server_ip)),
389-
);
390-
}
391-
if let Some(metrics_server_port) = self.metrics_server_port {
392-
result.insert(
393-
"metrics_server_port".to_string(),
394-
Value::new(Some(&namespace), ValueKind::from(metrics_server_port)),
395-
);
396-
}
397-
if let Some(master_aggregator_endpoint) = self.master_aggregator_endpoint.clone() {
398-
result.insert(
399-
"master_aggregator_endpoint".to_string(),
400-
Value::new(
401-
Some(&namespace),
402-
ValueKind::from(Some(master_aggregator_endpoint)),
403-
),
404-
);
405-
}
406-
407-
Ok(result)
408-
}
409-
}
410-
411-
#[test]
412-
fn test_serve_command_collect() {
413-
let serve_command = ServeCommand {
414-
server_ip: Some("value_server_ip".to_string()),
415-
server_port: Some(8000),
416-
snapshot_directory: Some(PathBuf::from("/mithril/aggregator/")),
417-
disable_digests_cache: true,
418-
reset_digests_cache: true,
419-
allow_unparsable_block: true,
420-
enable_metrics_server: true,
421-
metrics_server_ip: Some("value_metrics_server_ip".to_string()),
422-
metrics_server_port: Some(8080),
423-
master_aggregator_endpoint: Some("value_master_aggregator_endpoint".to_string()),
424-
};
425-
426-
let result = serve_command.collect().unwrap().clone();
427-
let mut expected = HashMap::new();
428-
expected.insert(
429-
"server_ip".to_string(),
430-
Value::new(
431-
Some(&"clap arguments".to_string()),
432-
ValueKind::from("value_server_ip"),
433-
),
434-
);
435-
expected.insert(
436-
"server_port".to_string(),
437-
Value::new(
438-
Some(&"clap arguments".to_string()),
439-
ValueKind::from(8000_u64),
440-
),
441-
);
442-
expected.insert(
443-
"snapshot_directory".to_string(),
444-
Value::new(
445-
Some(&"clap arguments".to_string()),
446-
ValueKind::from("/mithril/aggregator/"),
447-
),
448-
);
449-
expected.insert(
450-
"disable_digests_cache".to_string(),
451-
Value::new(Some(&"clap arguments".to_string()), ValueKind::from(true)),
452-
);
453-
expected.insert(
454-
"reset_digests_cache".to_string(),
455-
Value::new(Some(&"clap arguments".to_string()), ValueKind::from(true)),
456-
);
457-
expected.insert(
458-
"allow_unparsable_block".to_string(),
459-
Value::new(Some(&"clap arguments".to_string()), ValueKind::from(true)),
460-
);
461-
expected.insert(
462-
"enable_metrics_server".to_string(),
463-
Value::new(Some(&"clap arguments".to_string()), ValueKind::from(true)),
464-
);
465-
expected.insert(
466-
"metrics_server_ip".to_string(),
467-
Value::new(
468-
Some(&"clap arguments".to_string()),
469-
ValueKind::from("value_metrics_server_ip"),
470-
),
471-
);
472-
expected.insert(
473-
"metrics_server_port".to_string(),
474-
Value::new(
475-
Some(&"clap arguments".to_string()),
476-
ValueKind::from(Some(8080_u64)),
477-
),
478-
);
479-
expected.insert(
480-
"master_aggregator_endpoint".to_string(),
481-
Value::new(
482-
Some(&"clap arguments".to_string()),
483-
ValueKind::from("value_master_aggregator_endpoint"),
484-
),
485-
);
486-
487-
assert_eq!(expected, result);
488-
489-
assert_eq!(serve_command.collect_legacy().unwrap(), result);
490-
}
491-
492-
#[test]
493-
fn test_serve_command_collect_when_empty_values() {
494-
let serve_command = ServeCommand {
495-
server_ip: None,
496-
server_port: None,
497-
snapshot_directory: None,
498-
disable_digests_cache: false,
499-
reset_digests_cache: false,
500-
allow_unparsable_block: false,
501-
enable_metrics_server: false,
502-
metrics_server_ip: None,
503-
metrics_server_port: None,
504-
master_aggregator_endpoint: None,
505-
};
506-
507-
let result = serve_command.collect().unwrap().clone();
508-
let expected = HashMap::new();
509-
510-
assert_eq!(expected, result);
511-
512-
assert_eq!(serve_command.collect_legacy().unwrap(), result);
513-
}
514-
}

0 commit comments

Comments
 (0)