diff --git a/.github/workflows/live-tests.yml b/.github/workflows/live-tests.yml new file mode 100644 index 0000000..a221f57 --- /dev/null +++ b/.github/workflows/live-tests.yml @@ -0,0 +1,41 @@ +name: Live Tests +on: + # run by hand from the Actions tab + workflow_dispatch: + schedule: + # weekly, to catch Deezer changing an endpoint or data these tests depend on + - cron: '41 6 * * 1' + pull_request: + # only when this workflow or the code the live tests cover changes; the build workflow covers everything else + paths: + - .github/workflows/live-tests.yml + - DeezNET/DeezerURL.cs + - DeezNET.Tests/DeezerURLTests.cs + +permissions: + contents: read + +env: + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + DOTNET_CLI_TELEMETRY_OPTOUT: true + DOTNET_NOLOGO: true + DOTNET_VERSION: 8.0.405 + +jobs: + live: + runs-on: ubuntu-24.04 + steps: + - name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - name: Setup .NET + uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0 + with: + dotnet-version: ${{ env.DOTNET_VERSION }} + - name: Pin the SDK + run: | + echo '{"sdk":{"version": "${{ env.DOTNET_VERSION }}"}}' > ./global.json + - name: Run live tests + # these call Deezer's public API without an ARL; each failing case is listed in the log + run: dotnet test DeezNET.Tests -c Release --filter "Category=Live" --logger "console;verbosity=normal" diff --git a/DeezNET.Tests/DeezerURLTests.cs b/DeezNET.Tests/DeezerURLTests.cs index 00d585a..bdba409 100644 --- a/DeezNET.Tests/DeezerURLTests.cs +++ b/DeezNET.Tests/DeezerURLTests.cs @@ -58,15 +58,12 @@ public void UnshortenURLTest(string shortened, string expected) unshort.ShouldBe(expected); } - // it's very possible for the Artist and ArtistTop values to change later // calls Deezer, so CI skips it with --filter "Category!=Live" [Trait("Category", "Live")] [Theory] [InlineData("https://www.deezer.com/en/track/13787884", new long[] { 13787884 })] [InlineData("https://www.deezer.com/en/album/509603971", new long[] { 2531592621, 2531592631, 2531592641, 2531592651, 2531592661 })] [InlineData("https://www.deezer.com/en/playlist/12668949561", new long[] { 2664944792, 856599752, 134784964 })] - [InlineData("https://www.deezer.com/en/artist/11696461", new long[] { 938758732, 938758742, 938758752, 938758762, 938758772, 938758782, 938758792, 938758802, 938758812, 938758822, 140025373 })] - [InlineData("https://www.deezer.com/en/artist/11696461/top_track", new long[] { 140025373 })] public async Task GetAssociatedTracksTest(string url, long[] associatedTracks) { DeezerClient cli = new(); @@ -76,5 +73,23 @@ public async Task GetAssociatedTracksTest(string url, long[] associatedTracks) actualTracks.ShouldBeEquivalentTo(associatedTracks); } + + // an artist's catalogue and top tracks grow as they release more, so only check that known tracks are still included + // calls Deezer, so CI skips it with --filter "Category!=Live" + [Trait("Category", "Live")] + [Theory] + [InlineData("https://www.deezer.com/en/artist/11696461", new long[] { 938758732, 938758742, 938758752, 938758762, 938758772, 938758782, 938758792, 938758802, 938758812, 938758822, 140025373 })] + [InlineData("https://www.deezer.com/en/artist/11696461/top_track", new long[] { 140025373 })] + public async Task GetAssociatedArtistTracksTest(string url, long[] includedTracks) + { + DeezerClient cli = new(); + var data = DeezerURL.Parse(url); + + long[] actualTracks = await data.GetAssociatedTracks(cli); + + actualTracks.ShouldBeUnique(); + foreach (long track in includedTracks) + actualTracks.ShouldContain(track); + } } } \ No newline at end of file