summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJustin Wernick <justin@worthe-it.co.za>2023-03-16 22:51:00 +0200
committerJustin Wernick <justin@worthe-it.co.za>2023-03-16 22:51:00 +0200
commitb541b141e66d5cf0ba4b190eda6422126951af6e (patch)
tree7c183c941972266ffc14844ce48e39a5475ceff6 /tests
parent3035f8d52efe33749a8c027e193559ee7dd4c357 (diff)
Git push
Diffstat (limited to 'tests')
-rw-r--r--tests/server_shell.rs51
1 files changed, 44 insertions, 7 deletions
diff --git a/tests/server_shell.rs b/tests/server_shell.rs
index 5028ac9..ff3e1a4 100644
--- a/tests/server_shell.rs
+++ b/tests/server_shell.rs
@@ -3,7 +3,7 @@ use assert_cmd::{cargo::cargo_bin, Command};
use get_port::{tcp::TcpPort, Ops, Range};
use once_cell::sync::Lazy;
use rexpect::session::{spawn_command, PtySession};
-use std::{io, path, sync::Mutex};
+use std::{fs, io, path, sync::Mutex};
use tempfile::TempDir;
use thiserror::Error;
@@ -149,12 +149,7 @@ fn shows_a_prompt() -> Result<()> {
Ok(())
}
-#[test]
-fn git_clone_works_with_an_empty_repo() -> Result<()> {
- let c = spawn_ssh_server()?;
- let repo_name = "my-new-repo";
- make_new_repo(&c, repo_name)?;
-
+fn clone_git_repo(c: &TestContext, repo_name: &str) {
Command::new("git")
.args([
"clone",
@@ -167,6 +162,48 @@ fn git_clone_works_with_an_empty_repo() -> Result<()> {
.timeout(std::time::Duration::from_secs(3))
.assert()
.success();
+}
+
+#[test]
+fn git_clone_works_with_an_empty_repo() -> Result<()> {
+ let c = spawn_ssh_server()?;
+ let repo_name = "my-new-clonable-repo";
+ make_new_repo(&c, repo_name)?;
+ clone_git_repo(&c, repo_name);
+
+ Ok(())
+}
+
+#[test]
+fn git_push_works() -> Result<()> {
+ let c = spawn_ssh_server()?;
+ let repo_name = "my-new-pushable-repo";
+ make_new_repo(&c, repo_name)?;
+ clone_git_repo(&c, repo_name);
+
+ let repo_dir = c.workdir.as_ref().join(repo_name);
+
+ let file_name = "yay-a-file";
+ let file_path = repo_dir.join(file_name);
+ fs::write(&file_path, "doesn't matter what this is")?;
+
+ Command::new("git")
+ .args(["add", "-A"])
+ .current_dir(&repo_dir)
+ .assert()
+ .success();
+ Command::new("git")
+ .args(["commit", "-m", "commitment"])
+ .current_dir(&repo_dir)
+ .assert()
+ .success();
+
+ Command::new("git")
+ .args(["push", "origin"])
+ .current_dir(&repo_dir)
+ .timeout(std::time::Duration::from_secs(3))
+ .assert()
+ .success();
Ok(())
}