From 99714b4b29a42df79e9a2a9f6bc50baa413b8e8e Mon Sep 17 00:00:00 2001 From: qwjyh Date: Thu, 27 Feb 2025 01:07:44 +0900 Subject: [PATCH] update(test): use sync command The first sync from 2nd device didn't work, maybe due to that it is the first push. --- tests/cli.rs | 47 +++++++++++++++++------------------------------ 1 file changed, 17 insertions(+), 30 deletions(-) diff --git a/tests/cli.rs b/tests/cli.rs index 44e93cd..b282410 100644 --- a/tests/cli.rs +++ b/tests/cli.rs @@ -2,6 +2,7 @@ mod integrated_test { use std::{ fs::{self, DirBuilder, File}, io::{self, BufWriter, Write}, + path, }; use anyhow::{anyhow, Context, Ok, Result}; @@ -72,6 +73,16 @@ mod integrated_test { Ok(()) } + fn run_sync_cmd(config_dir: &path::Path) -> Result<()> { + Command::cargo_bin("xdbm")? + .arg("-c") + .arg(config_dir) + .args(["sync", "-vvvv"]) + .assert() + .success(); + Ok(()) + } + #[test] fn single_device() -> Result<()> { let config_dir = assert_fs::TempDir::new()?; @@ -380,16 +391,8 @@ mod integrated_test { std::fs::read_to_string(config_dir_1.join("storages.yml"))?.contains("parent: gdrive1") ); - std::process::Command::new("git") - .arg("push") - .current_dir(&config_dir_1) - .assert() - .success(); - std::process::Command::new("git") - .arg("pull") - .current_dir(&config_dir_2) - .assert() - .success(); + run_sync_cmd(&config_dir_1)?; + run_sync_cmd(&config_dir_2)?; // bind // @@ -603,16 +606,8 @@ mod integrated_test { .and(predicate::str::contains("foodoc").not()), ); - std::process::Command::new("git") - .arg("push") - .current_dir(&config_dir_2) - .assert() - .success(); - std::process::Command::new("git") - .arg("pull") - .current_dir(&config_dir_1) - .assert() - .success(); + run_sync_cmd(&config_dir_2)?; + run_sync_cmd(&config_dir_1)?; // bind // @@ -727,16 +722,8 @@ mod integrated_test { .assert() .success(); - std::process::Command::new("git") - .arg("push") - .current_dir(&config_dir_1) - .assert() - .success(); - std::process::Command::new("git") - .arg("pull") - .current_dir(&config_dir_2) - .assert() - .success(); + run_sync_cmd(&config_dir_1)?; + run_sync_cmd(&config_dir_2)?; // backup add //