diff --git a/src/Modrinth.Net/Endpoints/VersionFile/IVersionFileEndpoint.cs b/src/Modrinth.Net/Endpoints/VersionFile/IVersionFileEndpoint.cs index d578b1c..16b62d1 100644 --- a/src/Modrinth.Net/Endpoints/VersionFile/IVersionFileEndpoint.cs +++ b/src/Modrinth.Net/Endpoints/VersionFile/IVersionFileEndpoint.cs @@ -44,8 +44,8 @@ Task DeleteVersionByHashAsync(string hash, /// The loaders to filter by /// The game versions to filter by /// The latest version of a project, that matches the filters - Task GetLatestVersionByHashAsync(string hash, HashAlgorithm hashAlgorithm = HashAlgorithm.Sha1, - string[]? loaders = null, string[]? gameVersions = null); + Task GetLatestVersionByHashAsync(string hash, HashAlgorithm hashAlgorithm, + string[] loaders, string[] gameVersions); /// /// Gets the latest version of multiple projects by a file hash @@ -56,6 +56,6 @@ Task DeleteVersionByHashAsync(string hash, /// The game versions to filter by /// A dictionary of hashes and their respective latest versions that match the filters Task> GetMultipleLatestVersionsByHashAsync(string[] hashes, - HashAlgorithm hashAlgorithm = HashAlgorithm.Sha1, - string[]? loaders = null, string[]? gameVersions = null); + HashAlgorithm hashAlgorithm, + string[] loaders, string[] gameVersions); } \ No newline at end of file diff --git a/src/Modrinth.Net/Endpoints/VersionFile/VersionFileEndpoint.cs b/src/Modrinth.Net/Endpoints/VersionFile/VersionFileEndpoint.cs index ef4857e..a5602ae 100644 --- a/src/Modrinth.Net/Endpoints/VersionFile/VersionFileEndpoint.cs +++ b/src/Modrinth.Net/Endpoints/VersionFile/VersionFileEndpoint.cs @@ -72,12 +72,9 @@ public async Task DeleteVersionByHashAsync(string hash, HashAlgorithm hashAlgori /// public async Task GetLatestVersionByHashAsync(string hash, - HashAlgorithm hashAlgorithm = HashAlgorithm.Sha1, - string[]? loaders = null, string[]? gameVersions = null) + HashAlgorithm hashAlgorithm, + string[] loaders, string[] gameVersions) { - loaders = loaders ?? Array.Empty(); - gameVersions = gameVersions ?? Array.Empty(); - var reqMsg = new HttpRequestMessage(); reqMsg.Method = HttpMethod.Post; reqMsg.RequestUri = new Uri(VersionFilePathSegment + '/' + hash + "/update", UriKind.Relative); @@ -103,12 +100,9 @@ public async Task DeleteVersionByHashAsync(string hash, HashAlgorithm hashAlgori /// public async Task> GetMultipleLatestVersionsByHashAsync(string[] hashes, - HashAlgorithm hashAlgorithm = HashAlgorithm.Sha1, - string[]? loaders = null, string[]? gameVersions = null) + HashAlgorithm hashAlgorithm, + string[] loaders, string[] gameVersions) { - loaders = loaders ?? Array.Empty(); - gameVersions = gameVersions ?? Array.Empty(); - var reqMsg = new HttpRequestMessage(); reqMsg.Method = HttpMethod.Post; reqMsg.RequestUri = new Uri("version_files/update", UriKind.Relative); diff --git a/test/Modrinth.Net.Test/ModrinthApiTests/EndpointTests.cs b/test/Modrinth.Net.Test/ModrinthApiTests/EndpointTests.cs index 3bbcd95..6bd78d2 100644 --- a/test/Modrinth.Net.Test/ModrinthApiTests/EndpointTests.cs +++ b/test/Modrinth.Net.Test/ModrinthApiTests/EndpointTests.cs @@ -13,12 +13,12 @@ public class EndpointTests protected static readonly string[] ValidSha512Hashes = { - "f62b94dbdb7ec79c1cc9f7f01a07b72828e77d22426552cd876d0fa8ba2a446efaecaea262ed481b2f77fa57063a3bdcd1c5febb8ae97a766d82abf3eb9ee198", - "88014dd2d5fe7a259648eb716690f282e220556665ff20746bfa1f1d5a5f480e92fa94e07ea64db700c66720977d0c2147954efbf2c0c48bf38e419f04820453" + "bace1768e893e60574dcb1155e057a2fd0da3f3400c862a93c37dfe4d7908de1739b3b72190353f1a2a981ec18e1175d1dcf2109f0fb64ffdc73c45629a4cf55", + "3651e6cdb1dbb46580f27386caa01c88d28e51a5feec57cc435be73be25d718da9a719798e2b887e0fde14b6eaa970f30ee7220ff1f81489acd6174840c34d06" }; protected static readonly string[] ValidSha1Hashes = - {"7e64ba677dbae046389b63a4db324284355987db", "fde0d8156d8d46b2b0f9d09906ef7f83ce712517"}; + {"8b0a4139d9e82300b7aac82f2402ec3497991c52", "429eb439f0835e31fbbfd00234ef2daa8ecc8a87"}; private static readonly IConfigurationRoot Configuration = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build(); diff --git a/test/Modrinth.Net.Test/ModrinthApiTests/VersionFileTests.cs b/test/Modrinth.Net.Test/ModrinthApiTests/VersionFileTests.cs index 9d7101b..23498b7 100644 --- a/test/Modrinth.Net.Test/ModrinthApiTests/VersionFileTests.cs +++ b/test/Modrinth.Net.Test/ModrinthApiTests/VersionFileTests.cs @@ -66,56 +66,6 @@ public async Task GetMultipleVersionsFromHashesSha512() } [Test] - [TestCase(0)] - [TestCase(1)] - public async Task GetLatestVersionFromHashSha1(int index) - { - var hash = ValidSha1Hashes[index]; - - var version = await Client.VersionFile.GetLatestVersionByHashAsync(hash); - - Assert.That(version, Is.Not.Null); - - var versions = await Client.Version.GetProjectVersionListAsync(version.ProjectId); - - Assert.Multiple(() => - { - Assert.That(versions, Is.Not.Null); - Assert.That(versions, Is.Not.Empty); - - // We check that the version is the latest version - Assert.That(version.Id, Is.EqualTo(versions[0].Id)); - }); - } - - [Test] - [TestCase(0)] - [TestCase(1)] - public async Task GetLatestVersionFromHashSha512(int index) - { - var hash = ValidSha512Hashes[index]; - - var version = await Client.VersionFile.GetLatestVersionByHashAsync(hash, HashAlgorithm.Sha512); - - Assert.That(version, Is.Not.Null); - - var versions = await Client.Version.GetProjectVersionListAsync(version.ProjectId); - - Assert.Multiple(() => - { - Assert.That(versions, Is.Not.Null); - Assert.That(versions, Is.Not.Empty); - - // We check that the version is the latest version - Assert.That(version.Id, Is.EqualTo(versions[0].Id)); - }); - } - - [Test] - [TestCase(0, new string[] { }, new string[] { })] - [TestCase(0, new[] {"forge"}, new string[] { })] - [TestCase(0, new string[] { }, new[] {"1.18.1"})] - [TestCase(0, new[] {"quilt"}, new[] {"1.19"})] [TestCase(0, new[] {"fabric"}, new[] {"1.17.1"})] public async Task GetLatestVersionFromHashSha1WithFilters(int index, string[] loaders, string[] gameVersions) { @@ -133,10 +83,6 @@ public async Task GetLatestVersionFromHashSha1WithFilters(int index, string[] lo } [Test] - [TestCase(0, new string[] { }, new string[] { })] - [TestCase(0, new[] {"forge"}, new string[] { })] - [TestCase(0, new string[] { }, new[] {"1.18.1"})] - [TestCase(0, new[] {"quilt"}, new[] {"1.19"})] [TestCase(0, new[] {"fabric"}, new[] {"1.17.1"})] public async Task GetLatestVersionFromHashSha512WithFilters(int index, string[] loaders, string[] gameVersions) { @@ -154,40 +100,6 @@ public async Task GetLatestVersionFromHashSha512WithFilters(int index, string[] } [Test] - public async Task GetMultipleLatestVersionsFromHashSha1() - { - var hashes = ValidSha1Hashes; - - var versions = await Client.VersionFile.GetMultipleLatestVersionsByHashAsync(hashes); - - // We currently don't check if the versions are the latest versions - Assert.Multiple(() => - { - Assert.That(versions, Is.Not.Null); - Assert.That(versions, Is.Not.Empty); - }); - } - - [Test] - public async Task GetMultipleLatestVersionsFromHashSha512() - { - var hashes = ValidSha512Hashes; - - var versions = await Client.VersionFile.GetMultipleLatestVersionsByHashAsync(hashes, HashAlgorithm.Sha512); - - // We currently don't check if the versions are the latest versions - Assert.Multiple(() => - { - Assert.That(versions, Is.Not.Null); - Assert.That(versions, Is.Not.Empty); - }); - } - - [Test] - [TestCase(0, new string[] { }, new string[] { })] - [TestCase(0, new[] {"forge"}, new string[] { })] - [TestCase(0, new string[] { }, new[] {"1.18.1"})] - [TestCase(0, new[] {"quilt"}, new[] {"1.19"})] [TestCase(0, new[] {"fabric"}, new[] {"1.17.1"})] public async Task GetMultipleLatestVersionsFromHashSha1WithFilters(int index, string[] loaders, string[] gameVersions) @@ -212,10 +124,6 @@ await Client.VersionFile.GetMultipleLatestVersionsByHashAsync(hashes, HashAlgori } [Test] - [TestCase(0, new string[] { }, new string[] { })] - [TestCase(0, new[] {"forge"}, new string[] { })] - [TestCase(0, new string[] { }, new[] {"1.18.1"})] - [TestCase(0, new[] {"quilt"}, new[] {"1.19"})] [TestCase(0, new[] {"fabric"}, new[] {"1.17.1"})] public async Task GetMultipleLatestVersionsFromHashSha512WithFilters(int index, string[] loaders, string[] gameVersions)