fix(tests): fix testsuite allow to pass push

This commit is contained in:
grimhilt
2024-03-16 23:57:01 +01:00
parent 7180647d26
commit a1b9cde71a
10 changed files with 60 additions and 48 deletions

View File

@@ -1,9 +1,9 @@
mod utils;
use utils::{utils::*, status_utils::*, server::ServerTest, client::ClientTest};
use utils::{utils::*, server::ServerTest, client::ClientTest};
#[cfg(test)]
mod push_tests {
mod pull_tests {
use super::*;
#[test]
@@ -23,4 +23,23 @@ mod push_tests {
server.clean();
}
#[test]
fn simple_pull_directory() {
let id = get_random_test_id();
let mut server = ServerTest::new(id.clone());
server.init();
let mut client = ClientTest::new(id).init();
let _ = server.add_dir("dir");
let _ = server.add_file("dir/file1", "foo");
client.run_cmd_ok("pull");
// tests
assert!(client.has_file("dir/file1", "foo"));
client.clean();
server.clean();
}
}

View File

@@ -6,7 +6,7 @@ pub fn has_files(full_path: PathBuf, file: &str, content: &str, test_id: String)
{
if !full_path.exists() {
println!("id: {}", test_id.clone());
eprintln!("File '{}' doesn't exists on the server", file);
eprintln!("File '{}' doesn't exists", file);
return false;
}

View File

@@ -28,9 +28,9 @@ impl ServerTest {
}
pub fn init(&mut self) -> &mut ServerTest{
self.add_dir(self.test_id.clone());
self.add_dir(&self.test_id.clone());
self.volume = self.volume.join(self.test_id.clone());
self.sync_test();
self.sync_root();
self
}
@@ -40,7 +40,7 @@ impl ServerTest {
self
}
pub fn add_dir(&mut self, path: String) -> &mut ServerTest {
pub fn add_dir(&mut self, path: &str) -> &mut ServerTest {
let mut full_path = self.volume.clone();
full_path.push(path);
@@ -55,6 +55,11 @@ impl ServerTest {
Err(e) => eprintln!("Error creating directory: {}", e),
}
// do not sync test directory when creating it
if !path.ends_with("_nextsync")
{
self.sync_test();
}
self
}
@@ -73,6 +78,7 @@ impl ServerTest {
full_path.push(path);
let _ = fs::remove_dir_all(&full_path);
self.sync_test();
self
}
@@ -89,17 +95,12 @@ impl ServerTest {
// perform the occ files:scan command inside the nextcloud docker container
let nextcloud_docker = "master-nextcloud-1";
let mut args = String::from("exec -ti --user www-data");
args.push_str(nextcloud_docker);
args.push_str("/var/www/html/occ files:scan --path=/");
args.push_str(&self.user);
args.push_str("files/");
args.push_str(path);
let args = format!("exec -t --user www-data {} /var/www/html/occ files:scan --path=/{}/files/{}", nextcloud_docker, &self.user, path);
let _output = Command::new("docker")
.args(args.split(" "))
.output()
.expect("Could not execute nextsync command");
.expect("Could not execute docker exec command");
self
}