From d2df0f2b06d91aaae0f29db4cae684a825c2db64 Mon Sep 17 00:00:00 2001 From: ThetaDev Date: Wed, 23 Oct 2024 23:16:17 +0200 Subject: [PATCH 1/6] tmp: expect authentication --- tests/youtube.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/youtube.rs b/tests/youtube.rs index fe742a7..f68a4c3 100644 --- a/tests/youtube.rs +++ b/tests/youtube.rs @@ -246,10 +246,10 @@ async fn get_player( #[case] is_live_content: bool, rp: RustyPipe, ) { - if id == "ZDKQmBWTRnw" && !rp.query().auth_enabled() { - tracing::warn!("unauthenticated; age-limited video cannot be tested"); - return; - } + // if id == "ZDKQmBWTRnw" && !rp.query().auth_enabled() { + // tracing::warn!("unauthenticated; age-limited video cannot be tested"); + // return; + // } let player_data = rp.query().player(id).await.unwrap(); let details = player_data.details; From e5ca368d3f4cbcef5aa61f0f8d7089ee11db8770 Mon Sep 17 00:00:00 2001 From: ThetaDev Date: Wed, 23 Oct 2024 23:38:46 +0200 Subject: [PATCH 2/6] tmp: add debug print --- .forgejo/workflows/ci.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.forgejo/workflows/ci.yaml b/.forgejo/workflows/ci.yaml index 60230e6..afac4df 100644 --- a/.forgejo/workflows/ci.yaml +++ b/.forgejo/workflows/ci.yaml @@ -30,6 +30,8 @@ jobs: - name: ๐Ÿงช Test run: | echo "${{ secrets.RUSTYPIPE_CACHE }}" > rustypipe_cache.json + ls + head -n 1 rustypipe_cache.json cargo nextest run --config-file ~/.config/nextest.toml --profile ci --retries 2 --features rss --workspace env: ALL_PROXY: "http://warpproxy:8124" From e457733244003e750d6891fe771452783e4d7720 Mon Sep 17 00:00:00 2001 From: ThetaDev Date: Wed, 23 Oct 2024 23:51:37 +0200 Subject: [PATCH 3/6] test: check user_login --- tests/youtube.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/youtube.rs b/tests/youtube.rs index f68a4c3..8b9dcc3 100644 --- a/tests/youtube.rs +++ b/tests/youtube.rs @@ -2675,6 +2675,13 @@ async fn isrc_search_languages(rp: RustyPipe) { } } +#[rstest] +#[tokio::test] +async fn user_login(rp: RustyPipe) { + assert!(rp.query().auth_enabled()); + rp.user_auth_check_login().await.unwrap(); +} + //#TESTUTIL /// Get the language setting from the environment variable From 5459b88660486a78d2468e2712490c4c17c0bd99 Mon Sep 17 00:00:00 2001 From: ThetaDev Date: Wed, 23 Oct 2024 23:58:32 +0200 Subject: [PATCH 4/6] test: tree after running tests --- .forgejo/workflows/ci.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.forgejo/workflows/ci.yaml b/.forgejo/workflows/ci.yaml index afac4df..caee538 100644 --- a/.forgejo/workflows/ci.yaml +++ b/.forgejo/workflows/ci.yaml @@ -46,6 +46,8 @@ jobs: - name: ๐Ÿ”— Artifactview PR comment if: ${{ always() && github.event_name == 'pull_request' }} run: | + sudo apt-get install tree -y + tree . if [[ "$GITEA_ACTIONS" == "true" ]]; then RUN_NUMBER="$GITHUB_RUN_NUMBER"; else RUN_NUMBER="$GITHUB_RUN_ID"; fi curl -SsL --fail-with-body -w "\n" -X POST https://av.thetadev.de/.well-known/api/prComment -H "Content-Type: application/json" \ --data '{"url": "'"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$RUN_NUMBER"'", "pr": ${{ github.event.number }}, "artifact_titles": {"test":"๐Ÿงช Test report"}, "artifact_paths": {"test":"/junit.xml?viewer=1"}}' From a9b33fb882bce0a772913d218dccad3c872f08cb Mon Sep 17 00:00:00 2001 From: ThetaDev Date: Thu, 24 Oct 2024 00:03:44 +0200 Subject: [PATCH 5/6] test: dont add cache file --- .forgejo/workflows/ci.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.forgejo/workflows/ci.yaml b/.forgejo/workflows/ci.yaml index caee538..9ac21f7 100644 --- a/.forgejo/workflows/ci.yaml +++ b/.forgejo/workflows/ci.yaml @@ -29,9 +29,6 @@ jobs: - name: ๐Ÿงช Test run: | - echo "${{ secrets.RUSTYPIPE_CACHE }}" > rustypipe_cache.json - ls - head -n 1 rustypipe_cache.json cargo nextest run --config-file ~/.config/nextest.toml --profile ci --retries 2 --features rss --workspace env: ALL_PROXY: "http://warpproxy:8124" From 4e5fb1d89805c2b83cf3f1361f39394f82ed8ebb Mon Sep 17 00:00:00 2001 From: ThetaDev Date: Thu, 24 Oct 2024 00:30:49 +0200 Subject: [PATCH 6/6] test: hopefully fixed RUSTYPIPE_CACHE --- .forgejo/workflows/ci.yaml | 7 +++++-- src/client/mod.rs | 16 ++++++++-------- tests/youtube.rs | 3 +++ 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/.forgejo/workflows/ci.yaml b/.forgejo/workflows/ci.yaml index 9ac21f7..eebe019 100644 --- a/.forgejo/workflows/ci.yaml +++ b/.forgejo/workflows/ci.yaml @@ -29,9 +29,14 @@ jobs: - name: ๐Ÿงช Test run: | + printf "$RUSTYPIPE_CACHE" > rustypipe_cache.json + ls + head -n 1 rustypipe_cache.json + RUST_LOG=debug cargo test --package rustypipe --test youtube --features rss -- user_login --exact --nocapture cargo nextest run --config-file ~/.config/nextest.toml --profile ci --retries 2 --features rss --workspace env: ALL_PROXY: "http://warpproxy:8124" + RUSTYPIPE_CACHE: "${{ secrets.RUSTYPIPE_CACHE }}" - name: ๐Ÿ’Œ Upload test report if: always() @@ -43,8 +48,6 @@ jobs: - name: ๐Ÿ”— Artifactview PR comment if: ${{ always() && github.event_name == 'pull_request' }} run: | - sudo apt-get install tree -y - tree . if [[ "$GITEA_ACTIONS" == "true" ]]; then RUN_NUMBER="$GITHUB_RUN_NUMBER"; else RUN_NUMBER="$GITHUB_RUN_ID"; fi curl -SsL --fail-with-body -w "\n" -X POST https://av.thetadev.de/.well-known/api/prComment -H "Content-Type: application/json" \ --data '{"url": "'"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$RUN_NUMBER"'", "pr": ${{ github.event.number }}, "artifact_titles": {"test":"๐Ÿงช Test report"}, "artifact_paths": {"test":"/junit.xml?viewer=1"}}' diff --git a/src/client/mod.rs b/src/client/mod.rs index 4dee6f7..47788d1 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -605,17 +605,17 @@ impl RustyPipeBuilder { Box::new(FileStorage::new(cache_file)) }); - let mut cdata = storage - .as_ref() - .and_then(|storage| storage.read()) - .and_then(|data| match serde_json::from_str::(&data) { - Ok(data) => Some(data), + let mut cdata = if let Some(data) = storage.as_ref().and_then(|storage| storage.read()) { + match serde_json::from_str::(&data) { + Ok(data) => data, Err(e) => { tracing::error!("Could not deserialize cache. Error: {}", e); - None + CacheData::default() } - }) - .unwrap_or_default(); + } + } else { + CacheData::default() + }; let cache_clients = [ ClientType::Desktop, diff --git a/tests/youtube.rs b/tests/youtube.rs index 8b9dcc3..c535c95 100644 --- a/tests/youtube.rs +++ b/tests/youtube.rs @@ -7,6 +7,7 @@ use std::str::FromStr; use rstest::{fixture, rstest}; use rustypipe::param::{AlbumOrder, LANGUAGES}; use time::{macros::date, OffsetDateTime}; +use tracing_test::traced_test; use rustypipe::client::{ClientType, RustyPipe, RustyPipeQuery}; use rustypipe::error::{Error, ExtractionError, UnavailabilityReason}; @@ -2677,7 +2678,9 @@ async fn isrc_search_languages(rp: RustyPipe) { #[rstest] #[tokio::test] +#[traced_test] async fn user_login(rp: RustyPipe) { + tracing::debug!("test"); assert!(rp.query().auth_enabled()); rp.user_auth_check_login().await.unwrap(); }