aboutsummaryrefslogtreecommitdiff
path: root/src/command/add_remote.rs
diff options
context:
space:
mode:
authorRuben Beltran del Rio <git@r.bdr.sh>2025-01-18 22:07:14 +0100
committerRuben Beltran del Rio <git@r.bdr.sh>2025-01-18 22:07:14 +0100
commit26c24bf226ca647793fdafbc5cda7c9c4646d147 (patch)
tree9647d507226adee11a690f06ff17fc622b62a7c5 /src/command/add_remote.rs
parent88c54a37d27ed6a5eba3cb1911723a7e331f5bd3 (diff)
add more command tests
Diffstat (limited to 'src/command/add_remote.rs')
-rw-r--r--src/command/add_remote.rs67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/command/add_remote.rs b/src/command/add_remote.rs
index e5ca591..a40b184 100644
--- a/src/command/add_remote.rs
+++ b/src/command/add_remote.rs
@@ -42,3 +42,70 @@ impl super::Command for AddRemote {
"<git_url>\t\tAdds or updates a git remote to sync with"
}
}
+
+#[cfg(test)]
+mod tests {
+
+ use super::*;
+ use crate::command::Command;
+ use crate::configuration::Configuration;
+
+ use test_utilities::*;
+
+ #[test]
+ fn test_add_remote_command() {
+ let add_remote = AddRemote::new();
+
+ // Create all directories
+ let test_dir = setup_test_dir();
+ let remote_config = test_dir.join("blogremote");
+ assert!(!remote_config.exists());
+
+ let mut configuration = Configuration::new();
+ configuration.config_directory = test_dir.clone();
+ configuration.remote_config = remote_config.clone();
+ add_remote
+ .execute(Some(&"beep".to_string()), &configuration, "add_remote")
+ .expect("Could not call add_remote");
+ assert_file_contents(&remote_config, "beep");
+ cleanup_test_dir(&test_dir);
+ }
+
+ #[test]
+ fn test_fails_if_no_remote_sent() {
+ let add_remote = AddRemote::new();
+ let configuration = Configuration::new();
+ let result = add_remote.execute(None, &configuration, "add_remote");
+ assert!(result.is_err());
+ }
+
+ #[test]
+ fn add_remote_before_dependencies() {
+ let add_remote = AddRemote::new();
+ let dependencies = add_remote.before_dependencies();
+
+ assert_eq!(dependencies.len(), 0);
+ }
+
+ #[test]
+ fn add_remote_after_dependencies() {
+ let add_remote = AddRemote::new();
+ let dependencies = add_remote.after_dependencies();
+
+ assert_eq!(dependencies.len(), 0);
+ }
+
+ // These two tests feel pointless but I'm doing it for the coverage :p
+
+ #[test]
+ fn add_remote_command_output() {
+ let add_remote = AddRemote::new();
+ add_remote.command();
+ }
+
+ #[test]
+ fn add_remote_help_output() {
+ let add_remote = AddRemote::new();
+ add_remote.help();
+ }
+}