diff options
| author | Soispha Peetz <soispha@b-peetz.de> | 2026-11-28 21:25:40 +0100 |
|---|---|---|
| committer | Soispha Peetz <soispha@b-peetz.de> | 2026-11-28 21:25:40 +0100 |
| commit | 7513cce8228e1f6a62d5fadc4ecda363feb3ce85 (patch) | |
| tree | 01c3bc8a9a465936bf8ea0f5f91572f43d400d60 /crates | |
| parent | test(crates/yt/storage/db/video/comments): Replace macro by function (diff) | |
| download | yt-7513cce8228e1f6a62d5fadc4ecda363feb3ce85.zip | |
test(crates/yt/tests): Update the integration tests to the changes in yt
Diffstat (limited to 'crates')
| -rw-r--r-- | crates/yt/tests/_testenv/init.rs | 42 | ||||
| -rw-r--r-- | crates/yt/tests/_testenv/mod.rs | 1 | ||||
| -rw-r--r-- | crates/yt/tests/_testenv/run.rs | 5 | ||||
| -rw-r--r-- | crates/yt/tests/subscriptions/import_export/golden.txt | 4 | ||||
| -rw-r--r-- | crates/yt/tests/subscriptions/naming_subscriptions/golden.txt | 4 |
5 files changed, 37 insertions, 19 deletions
diff --git a/crates/yt/tests/_testenv/init.rs b/crates/yt/tests/_testenv/init.rs index ff88d46..93b1d4d 100644 --- a/crates/yt/tests/_testenv/init.rs +++ b/crates/yt/tests/_testenv/init.rs @@ -10,25 +10,32 @@ // If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>. use std::{ - env, - fs::{self, OpenOptions}, - io::{self, Write}, - path::PathBuf, + env, fs::{self, OpenOptions, Permissions}, io::{self, Write}, os::unix::fs::PermissionsExt, path::PathBuf, process::Command, }; use crate::{_testenv::Paths, testenv::TestEnv}; fn target_dir() -> PathBuf { - // Tests exe is in target/debug/deps, the *yt* exe is in target/debug - env::current_exe() - .expect("./target/debug/deps/yt-*") - .parent() - .expect("./target/debug/deps") - .parent() - .expect("./target/debug") - .parent() - .expect("./target") - .to_path_buf() + let root = { + let output = Command::new("git") + .args(["rev-parse", "--show-toplevel"]) + .output() + .expect("git failed"); + + assert!(output.status.success()); + + PathBuf::from( + String::from_utf8(output.stdout) + .expect("git not utf8") + .trim(), + ) + }; + + let target = root.join("target"); + + assert!(target.is_dir()); + + target } fn test_dir(name: &'static str) -> PathBuf { @@ -44,6 +51,7 @@ fn prepare_files_and_dirs(name: &'static str) -> io::Result<Paths> { let last_selection_path = test_dir.join("last_selection"); let config_path = test_dir.join("config.toml"); let download_dir = test_dir.join("download"); + let runtime = test_dir.join("xdg_runtime"); { // Remove all files, that are not the download dir. @@ -64,6 +72,11 @@ fn prepare_files_and_dirs(name: &'static str) -> io::Result<Paths> { } fs::create_dir_all(&download_dir)?; + fs::create_dir_all(&runtime)?; + fs::set_permissions( + &runtime, + Permissions::from_mode(0o700), + )?; { let mut config_file = OpenOptions::new() @@ -99,6 +112,7 @@ max_backlog = 1 last_selection: last_selection_path, config: config_path, download_dir, + runtime, }) } diff --git a/crates/yt/tests/_testenv/mod.rs b/crates/yt/tests/_testenv/mod.rs index adf17ca..4ef3f97 100644 --- a/crates/yt/tests/_testenv/mod.rs +++ b/crates/yt/tests/_testenv/mod.rs @@ -33,4 +33,5 @@ pub(crate) struct Paths { pub(crate) last_selection: PathBuf, pub(crate) config: PathBuf, pub(crate) download_dir: PathBuf, + pub(crate) runtime: PathBuf, } diff --git a/crates/yt/tests/_testenv/run.rs b/crates/yt/tests/_testenv/run.rs index b313353..ac0a5b3 100644 --- a/crates/yt/tests/_testenv/run.rs +++ b/crates/yt/tests/_testenv/run.rs @@ -162,12 +162,15 @@ impl TestEnv { cmd.args([ "-v", - "--color", + "--option", + "global.display_colors", "false", "--config-path", self.paths.config.to_str().unwrap(), ]); + cmd.env("XDG_RUNTIME_DIR", self.paths.runtime.clone()); + cmd.stdout(Stdio::piped()); cmd.stderr(Stdio::piped()); diff --git a/crates/yt/tests/subscriptions/import_export/golden.txt b/crates/yt/tests/subscriptions/import_export/golden.txt index 7ed5419..c98b723 100644 --- a/crates/yt/tests/subscriptions/import_export/golden.txt +++ b/crates/yt/tests/subscriptions/import_export/golden.txt @@ -1,2 +1,2 @@ -Nyheter på lätt svenska: 'https://www.svtplay.se/nyheter-pa-latt-svenska' -tagesschau: 'https://www.ardmediathek.de/sendung/tagesschau/Y3JpZDovL2Rhc2Vyc3RlLmRlL3RhZ2Vzc2NoYXU' +Nyheter på lätt svenska: 'https://www.svtplay.se/nyheter-pa-latt-svenska' (active) +tagesschau: 'https://www.ardmediathek.de/sendung/tagesschau/Y3JpZDovL2Rhc2Vyc3RlLmRlL3RhZ2Vzc2NoYXU' (active) diff --git a/crates/yt/tests/subscriptions/naming_subscriptions/golden.txt b/crates/yt/tests/subscriptions/naming_subscriptions/golden.txt index 46ede50..6be5e23 100644 --- a/crates/yt/tests/subscriptions/naming_subscriptions/golden.txt +++ b/crates/yt/tests/subscriptions/naming_subscriptions/golden.txt @@ -1,2 +1,2 @@ -Nyheter: 'https://www.svtplay.se/nyheter-pa-latt-svenska' -Vewn: 'https://www.ardmediathek.de/sendung/tagesschau/Y3JpZDovL2Rhc2Vyc3RlLmRlL3RhZ2Vzc2NoYXU' +Nyheter: 'https://www.svtplay.se/nyheter-pa-latt-svenska' (active) +Vewn: 'https://www.ardmediathek.de/sendung/tagesschau/Y3JpZDovL2Rhc2Vyc3RlLmRlL3RhZ2Vzc2NoYXU' (active) |
