From 51dacf8df299c47994e8fac4ed5b0ffd29e480bb Mon Sep 17 00:00:00 2001 From: ThetaDev Date: Mon, 13 Jan 2025 03:46:45 +0100 Subject: [PATCH] ci: skip authenticated tests --- .forgejo/workflows/ci.yaml | 8 +- Justfile | 11 +- tests/youtube.rs | 229 ++++++++++++++----------------------- 3 files changed, 97 insertions(+), 151 deletions(-) diff --git a/.forgejo/workflows/ci.yaml b/.forgejo/workflows/ci.yaml index 325cc80..3f6ec46 100644 --- a/.forgejo/workflows/ci.yaml +++ b/.forgejo/workflows/ci.yaml @@ -28,15 +28,9 @@ jobs: run: cargo clippy --all --tests --features=rss,indicatif,audiotag -- -D warnings - name: 🧪 Test - run: | - printf '%s\n' "$RUSTYPIPE_CACHE" > rustypipe_cache.json - echo "authenticated=$YT_AUTHENTICATED" - wc -c rustypipe_cache.json - cargo nextest run --config-file ~/.config/nextest.toml --profile ci --retries 2 --features rss --workspace + run: cargo nextest run --config-file ~/.config/nextest.toml --profile ci --retries 2 --features rss --workspace -- --skip 'cookie_auth::' env: ALL_PROXY: "http://warpproxy:8124" - RUSTYPIPE_CACHE: "${{ secrets.RUSTYPIPE_CACHE }}" - YT_AUTHENTICATED: "${{ secrets.RUSTYPIPE_CACHE != '' }}" - name: Move test report if: always() diff --git a/Justfile b/Justfile index fcf3068..76e8102 100644 --- a/Justfile +++ b/Justfile @@ -1,15 +1,19 @@ test: # cargo test --features=rss - cargo nextest run --workspace --features=rss --no-fail-fast --retries 1 + cargo nextest run --workspace --features=rss --no-fail-fast --retries 1 -- --skip 'cookie_auth::' unittest: cargo nextest run --features=rss --no-fail-fast --lib testyt: + cargo nextest run --features=rss --no-fail-fast --retries 1 --test youtube -- --skip 'cookie_auth::' + +testyt-cookie: cargo nextest run --features=rss --no-fail-fast --retries 1 --test youtube testyt-localized: - YT_LANG=th cargo nextest run --features=rss --no-fail-fast ---retries 1 --test youtube + YT_LANG=th cargo nextest run --features=rss --no-fail-fast --retries 1 --test youtube -- \ + --skip 'cookie_auth::' --skip 'search_suggestion' --skip 'isrc_search_languages' testintl: #!/usr/bin/env bash @@ -28,7 +32,8 @@ testintl: for YT_LANG in "${LANGUAGES[@]}"; do echo "---TESTS FOR $YT_LANG ---" - if YT_LANG="$YT_LANG" cargo nextest run --no-fail-fast --retries 1 --test-threads 4 --test youtube -E 'not test(/^resolve/)'; then + if YT_LANG="$YT_LANG" cargo nextest run --no-fail-fast --retries 1 --test-threads 4 --test youtube -- \ + --skip 'cookie_auth::' --skip 'search_suggestion' --skip 'isrc_search_languages' --skip 'resolve_'; then echo "--- $YT_LANG COMPLETED ---" else echo "--- $YT_LANG FAILED ---" diff --git a/tests/youtube.rs b/tests/youtube.rs index 633032a..2a79c5c 100644 --- a/tests/youtube.rs +++ b/tests/youtube.rs @@ -2734,6 +2734,94 @@ async fn isrc_search_languages(rp: RustyPipe) { } } +mod cookie_auth { + use super::*; + + #[rstest] + #[tokio::test] + async fn history(rp: RustyPipe) { + let videos = rp.query().history().await.unwrap(); + assert_next_history(videos, rp.query(), 100).await; + } + + #[rstest] + #[tokio::test] + async fn history_search(rp: RustyPipe) { + let videos = rp.query().history_search("a").await.unwrap(); + assert_next_history(videos, rp.query(), 5).await; + } + + #[rstest] + #[tokio::test] + async fn subscriptions(rp: RustyPipe) { + let channels = rp.query().subscriptions().await.unwrap(); + assert_next_items(channels, rp.query(), 5).await; + } + + #[rstest] + #[tokio::test] + async fn subscription_feed(rp: RustyPipe) { + let videos = rp.query().subscription_feed().await.unwrap(); + assert_next_items(videos, rp.query(), 50).await; + } + + #[rstest] + #[tokio::test] + async fn liked_videos(rp: RustyPipe) { + let videos = rp.query().liked_videos().await.unwrap(); + assert_next_items(videos.videos, rp.query(), 5).await; + } + + #[rstest] + #[tokio::test] + async fn watch_later(rp: RustyPipe) { + let videos = rp.query().watch_later().await.unwrap(); + assert_next_items(videos.videos, rp.query(), 5).await; + } + + #[rstest] + #[tokio::test] + async fn music_history(rp: RustyPipe) { + let tracks = rp.query().music_history().await.unwrap(); + assert_next_music_history(tracks, rp.query(), 150).await; + } + + #[rstest] + #[tokio::test] + async fn music_saved_artists(rp: RustyPipe) { + let artists = rp.query().music_saved_artists().await.unwrap(); + assert_next_items(artists, rp.query(), 5).await; + } + + #[rstest] + #[tokio::test] + async fn music_saved_albums(rp: RustyPipe) { + let albums = rp.query().music_saved_albums().await.unwrap(); + assert_next_items(albums, rp.query(), 5).await; + } + + #[rstest] + #[tokio::test] + async fn music_saved_tracks(rp: RustyPipe) { + let tracks = rp.query().music_saved_tracks().await.unwrap(); + assert_next_items(tracks, rp.query(), 50).await; + } + + #[rstest] + #[tokio::test] + async fn music_saved_playlists(rp: RustyPipe) { + let playlists = rp.query().music_saved_playlists().await.unwrap(); + assert_next_items(playlists, rp.query(), 5).await; + } + + #[rstest] + #[tokio::test] + async fn music_liked_tracks(rp: RustyPipe) { + let tracks = rp.query().music_liked_tracks().await.unwrap(); + assert_next_items(tracks.tracks, rp.query(), 5).await; + } +} + #[rstest] #[tokio::test] async fn user_auth_check_login(rp: RustyPipe, auth_enabled: bool) { @@ -2743,138 +2831,6 @@ async fn user_auth_check_login(rp: RustyPipe, auth_enabled: bool) { } } -#[rstest] -#[tokio::test] -async fn history(rp: RustyPipe, cookie_auth_enabled: bool) { - if !cookie_auth_enabled { - return; - } - - let videos = rp.query().history().await.unwrap(); - assert_next_history(videos, rp.query(), 100).await; -} - -#[rstest] -#[tokio::test] -async fn history_search(rp: RustyPipe, cookie_auth_enabled: bool) { - if !cookie_auth_enabled { - return; - } - - let videos = rp.query().history_search("a").await.unwrap(); - assert_next_history(videos, rp.query(), 5).await; -} - -#[rstest] -#[tokio::test] -async fn subscriptions(rp: RustyPipe, cookie_auth_enabled: bool) { - if !cookie_auth_enabled { - return; - } - - let channels = rp.query().subscriptions().await.unwrap(); - assert_next_items(channels, rp.query(), 5).await; -} - -#[rstest] -#[tokio::test] -async fn subscription_feed(rp: RustyPipe, cookie_auth_enabled: bool) { - if !cookie_auth_enabled { - return; - } - - let videos = rp.query().subscription_feed().await.unwrap(); - assert_next_items(videos, rp.query(), 50).await; -} - -#[rstest] -#[tokio::test] -async fn liked_videos(rp: RustyPipe, cookie_auth_enabled: bool) { - if !cookie_auth_enabled { - return; - } - - let videos = rp.query().liked_videos().await.unwrap(); - assert_next_items(videos.videos, rp.query(), 5).await; -} - -#[rstest] -#[tokio::test] -async fn watch_later(rp: RustyPipe, cookie_auth_enabled: bool) { - if !cookie_auth_enabled { - return; - } - - let videos = rp.query().watch_later().await.unwrap(); - assert_next_items(videos.videos, rp.query(), 5).await; -} - -#[rstest] -#[tokio::test] -async fn music_history(rp: RustyPipe, cookie_auth_enabled: bool) { - if !cookie_auth_enabled { - return; - } - - let tracks = rp.query().music_history().await.unwrap(); - assert_next_music_history(tracks, rp.query(), 150).await; -} - -#[rstest] -#[tokio::test] -async fn music_saved_artists(rp: RustyPipe, cookie_auth_enabled: bool) { - if !cookie_auth_enabled { - return; - } - - let artists = rp.query().music_saved_artists().await.unwrap(); - assert_next_items(artists, rp.query(), 5).await; -} - -#[rstest] -#[tokio::test] -async fn music_saved_albums(rp: RustyPipe, cookie_auth_enabled: bool) { - if !cookie_auth_enabled { - return; - } - - let albums = rp.query().music_saved_albums().await.unwrap(); - assert_next_items(albums, rp.query(), 5).await; -} - -#[rstest] -#[tokio::test] -async fn music_saved_tracks(rp: RustyPipe, cookie_auth_enabled: bool) { - if !cookie_auth_enabled { - return; - } - - let tracks = rp.query().music_saved_tracks().await.unwrap(); - assert_next_items(tracks, rp.query(), 50).await; -} - -#[rstest] -#[tokio::test] -async fn music_saved_playlists(rp: RustyPipe, cookie_auth_enabled: bool) { - if !cookie_auth_enabled { - return; - } - - let playlists = rp.query().music_saved_playlists().await.unwrap(); - assert_next_items(playlists, rp.query(), 5).await; -} - -#[rstest] -#[tokio::test] -async fn music_liked_tracks(rp: RustyPipe, cookie_auth_enabled: bool) { - if !cookie_auth_enabled { - return; - } - - let tracks = rp.query().music_liked_tracks().await.unwrap(); - assert_next_items(tracks.tracks, rp.query(), 5).await; -} - //#TESTUTIL /// Get the language setting from the environment variable @@ -2914,15 +2870,6 @@ fn auth_enabled(rp: RustyPipe) -> bool { || rp.query().auth_enabled(ClientType::Tv) } -/// Get a flag signaling if an authenticated user is expected -#[fixture] -fn cookie_auth_enabled(rp: RustyPipe) -> bool { - std::env::var("YT_AUTHENTICATED") - .map(|v| !v.is_empty() && !v.eq_ignore_ascii_case("false")) - .unwrap_or_default() - || rp.query().auth_enabled(ClientType::Desktop) -} - /* /// Get a new RustyPipe instance with pre-set visitor data fn rp_visitor_data(vdata: &str) -> RustyPipe {