Scrobbling Polish and Some Scanner fixes (#3638)

Co-authored-by: Fesaa <77553571+Fesaa@users.noreply.github.com>
This commit is contained in:
Joe Milazzo 2025-03-15 11:13:01 -05:00 committed by GitHub
parent 82e8f7fade
commit f281a63934
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 658 additions and 102 deletions

View file

@ -1,4 +1,5 @@
using System;
using System.Threading.Tasks;
using API.Helpers;
using Xunit;
@ -33,7 +34,7 @@ public class RateLimiterTests
}
[Fact]
public void AcquireTokens_Refill()
public async Task AcquireTokens_Refill()
{
// Arrange
var limiter = new RateLimiter(2, TimeSpan.FromSeconds(1));
@ -43,14 +44,14 @@ public class RateLimiterTests
limiter.TryAcquire("test_key");
// Wait for refill
System.Threading.Thread.Sleep(1100);
await Task.Delay(1100);
// Assert
Assert.True(limiter.TryAcquire("test_key"));
}
[Fact]
public void AcquireTokens_Refill_WithOff()
public async Task AcquireTokens_Refill_WithOff()
{
// Arrange
var limiter = new RateLimiter(2, TimeSpan.FromSeconds(10), false);
@ -60,7 +61,7 @@ public class RateLimiterTests
limiter.TryAcquire("test_key");
// Wait for refill
System.Threading.Thread.Sleep(2100);
await Task.Delay(2100);
// Assert
Assert.False(limiter.TryAcquire("test_key"));

View file

@ -11,8 +11,22 @@ public class StringHelperTests
"<p>A Perfect Marriage Becomes a Perfect Affair!<br /> <br><br><br /> Every woman wishes for that happily ever after, but when time flies by and you've become a neglected housewife, what's a woman to do?</p>",
"<p>A Perfect Marriage Becomes a Perfect Affair!<br /> Every woman wishes for that happily ever after, but when time flies by and you've become a neglected housewife, what's a woman to do?</p>"
)]
public void Test(string input, string expected)
public void TestSquashBreaklines(string input, string expected)
{
Assert.Equal(expected, StringHelper.SquashBreaklines(input));
}
[Theory]
[InlineData(
"<p>A Perfect Marriage Becomes a Perfect Affair!<br /> (Source: Anime News Network)</p>",
"<p>A Perfect Marriage Becomes a Perfect Affair!<br /></p>"
)]
[InlineData(
"<p>A Perfect Marriage Becomes a Perfect Affair!<br /></p>(Source: Anime News Network)",
"<p>A Perfect Marriage Becomes a Perfect Affair!<br /></p>"
)]
public void TestRemoveSourceInDescription(string input, string expected)
{
Assert.Equal(expected, StringHelper.RemoveSourceInDescription(input));
}
}