Skip to content

Commit e927e9d

Browse files
authored
Merge pull request #122 from Zechiax/fixes
Fix more tests, update README
2 parents 60e9afe + e587552 commit e927e9d

File tree

7 files changed

+24
-14
lines changed

7 files changed

+24
-14
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ catch (ModrinthApiException e)
228228
| Change user's avatar | PATCH ||
229229
| Get user's projects | GET ||
230230
| Get user's followed projects | GET ||
231-
| Get user's payout history | GET | |
231+
| Get user's payout history | GET | |
232232
| Withdraw payout balance to PayPal or Venmo | POST ||
233233

234234
### Threads endpoints

src/Modrinth.Net/Endpoints/Project/IProjectEndpoint.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public interface IProjectEndpoint
1616
/// <param name="facets">Facets to filter the search by</param>
1717
/// <param name="index">The sorting method used for sorting search results</param>
1818
/// <param name="offset">The offset into the search. Skips this number of results</param>
19-
/// <param name="limit">The number of results returned by the search</param>
19+
/// <param name="limit">The number of results returned by the search. Must be greater than zero</param>
2020
/// <param name="cancellationToken"> The cancellation token to cancel operation </param>
2121
/// <returns></returns>
2222
/// <exception cref="ModrinthApiException"> Thrown when the API returns an error or the request fails </exception>

src/Modrinth.Net/Endpoints/Project/ProjectEndpoint.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,11 @@ public async Task DeleteGalleryImageAsync(string slugOrId, string url,
224224
public async Task<SearchResponse> SearchAsync(string query, Index index = Index.Downloads, ulong offset = 0,
225225
ulong limit = 10, FacetCollection? facets = null, CancellationToken cancellationToken = default)
226226
{
227+
if (limit <= 0)
228+
{
229+
throw new ArgumentOutOfRangeException(nameof(limit), "Limit must be greater than 0");
230+
}
231+
227232
var reqMsg = new HttpRequestMessage();
228233
reqMsg.Method = HttpMethod.Get;
229234
reqMsg.RequestUri = new Uri("search", UriKind.Relative);

test/Modrinth.Net.Test/ModrinthApiTests/EndpointTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class EndpointTests
2828
/// Must be users that have at least one project
2929
/// The first ID should be the ID of the user that will be authenticated
3030
/// </summary>
31-
protected readonly string[] TestUserIds = {"MaovZxtD", "5XoMa0C4"};
31+
protected readonly string[] TestUserIds = {"JZA4dW8o", "TEZXhE2U"};
3232

3333
protected IModrinthClient Client = null!;
3434
protected IModrinthClient NoAuthClient = null!;

test/Modrinth.Net.Test/ModrinthApiTests/ProjectColorTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public async Task ProjectColor()
2525
public async Task ProjectColor_WithNoColor()
2626
{
2727
// TODO: Don't use a hardcoded project slug
28-
var project = await Client.Project.GetAsync("test-project");
28+
var project = await Client.Project.GetAsync("nocolorproject");
2929

3030
// Check that the project color is not null
3131
Assert.That(project.Color, Is.Null);

test/Modrinth.Net.Test/ModrinthApiTests/SearchTests.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ public async Task Search_WithFabricSearchTerm_ShouldReturnNonEmptyList()
3333

3434
// Test different limit values
3535
[Test]
36-
[TestCase((ulong) 0)]
3736
[TestCase((ulong) 1)]
3837
[TestCase((ulong) 5)]
3938
[TestCase((ulong) 10)]
@@ -56,6 +55,12 @@ public async Task Search_WithLimit_ShouldReturnLimitedList(ulong limit)
5655
Assert.That(search.Hits, Is.Not.Empty);
5756
});
5857
}
58+
59+
[Test]
60+
public void Search_WithLimit0_ShouldThrowException()
61+
{
62+
Assert.ThrowsAsync<ArgumentOutOfRangeException>(async () => await Client.Project.SearchAsync("", limit: 0));
63+
}
5964

6065
// Test different offset values
6166
[Test]
@@ -66,7 +71,7 @@ public async Task Search_WithLimit_ShouldReturnLimitedList(ulong limit)
6671
public async Task Search_WithOffset_ShouldReturnOffsetList(ulong offset)
6772
{
6873
var search = await Client.Project.SearchAsync("", limit: offset + 5);
69-
var searchWithOffset = await Client.Project.SearchAsync("", offset: offset, limit: offset + 5);
74+
var searchWithOffset = await Client.Project.SearchAsync("", offset: offset, limit: offset);
7075

7176
// Check that the offset list is not the same as the original list
7277
Assert.That(searchWithOffset.Hits, Is.Not.EqualTo(search.Hits));

test/Modrinth.Net.Test/ModrinthApiTests/UserEndpointTests.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ public async Task GetMultipleUsers()
7373
}
7474
}
7575

76-
[Test]
77-
public async Task GetCurrentUserPayoutHistory()
78-
{
79-
var curUser = await Client.User.GetCurrentAsync();
80-
var history = await Client.User.GetPayoutHistoryAsync(curUser.Id);
81-
82-
Assert.That(history, Is.Not.Null);
83-
}
76+
// [Test]
77+
// public async Task GetCurrentUserPayoutHistory()
78+
// {
79+
// var curUser = await Client.User.GetCurrentAsync();
80+
// var history = await Client.User.GetPayoutHistoryAsync(curUser.Id);
81+
//
82+
// Assert.That(history, Is.Not.Null);
83+
// }
8484
}

0 commit comments

Comments
 (0)