Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test pr2 #1088

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Meziantou.Analyzer" Version="2.0.152">
<PackageReference Include="Meziantou.Analyzer" Version="2.0.153">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
20 changes: 12 additions & 8 deletions Minio.Functional.Tests/FunctionalTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* MinIO .NET Library for Amazon S3 Compatible Cloud Storage,
* (C) 2017-2021 MinIO, Inc.
*
Expand Down Expand Up @@ -364,7 +364,9 @@ internal static async Task BucketExists_Test(IMinioClient minio)

try
{
await minio.RemoveBucketAsync(rbArgs).ConfigureAwait(false);
if (await minio.BucketExistsAsync(beArgs).ConfigureAwait(false))
await minio.RemoveBucketAsync(rbArgs).ConfigureAwait(false);

var found = await minio.BucketExistsAsync(beArgs).ConfigureAwait(false);
Assert.IsFalse(found);
await minio.MakeBucketAsync(mbArgs).ConfigureAwait(false);
Expand Down Expand Up @@ -3505,8 +3507,9 @@ internal static async Task PutObject_Test9(IMinioClient minio)
var stream = rsg.GenerateStreamFromSeed(objSize);
var statObj = await PutObject_Tester(minio, bucketName, objectName, null, contentType, 0, null,
stream, progress).ConfigureAwait(false);
Assert.IsTrue(percentage == 100);
Assert.IsTrue(totalBytesTransferred == objSize);
Assert.IsTrue(percentage == 100, "Reported percentage after finished upload was not 100 percent.");
Assert.IsTrue(totalBytesTransferred == objSize,
"Transfered object size does not match with the original object size.");
new MintLogger(nameof(PutObject_Test9), putObjectSignature,
"Tests whether PutObject with progress passes for small object", TestStatus.PASS,
DateTime.Now - startTime,
Expand Down Expand Up @@ -3560,8 +3563,9 @@ internal static async Task PutObject_Test10(IMinioClient minio)
await Setup_Test(minio, bucketName).ConfigureAwait(false);
_ = await PutObject_Tester(minio, bucketName, objectName, null, contentType, 0, null,
rsg.GenerateStreamFromSeed(64 * MB), progress).ConfigureAwait(false);
Assert.IsTrue(percentage == 100);
Assert.IsTrue(totalBytesTransferred == 64 * MB);
Assert.IsTrue(percentage == 100, "Reported percentage after finished upload was not 100 percent.");
Assert.IsTrue(totalBytesTransferred == 64 * MB,
"Transfered object size does not match with the original object size.");
new MintLogger(nameof(PutObject_Test10), putObjectSignature,
"Tests whether multipart PutObject with progress passes", TestStatus.PASS, DateTime.Now - startTime,
args: args).Log();
Expand Down Expand Up @@ -4121,9 +4125,9 @@ internal static async Task CopyObject_Test7(IMinioClient minio)
}
catch (Exception ex)
{
Assert.AreEqual(
Assert.IsTrue(ex.Message.StartsWith(
"MinIO API responded with message=At least one of the pre-conditions you specified did not hold",
ex.Message);
StringComparison.InvariantCulture));
}

new MintLogger("CopyObject_Test7", copyObjectSignature,
Expand Down
2 changes: 1 addition & 1 deletion Minio.Functional.Tests/Minio.Functional.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MSTest.TestFramework" Version="3.3.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.4.0" />
<PackageReference Include="SharpZipLib" Version="1.4.2" />
<ProjectReference Include="..\Minio\Minio.csproj" />
</ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions Minio.Tests/Minio.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.3.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.3.1" />
<PackageReference Include="MSTest.TestAdapter" Version="3.4.0" />
<PackageReference Include="MSTest.TestFramework" Version="3.4.0" />
<PackageReference Include="Moq" Version="4.20.70" />
<ProjectReference Include="..\Minio\Minio.csproj" />
</ItemGroup>
Expand Down
11 changes: 6 additions & 5 deletions Minio/RequestExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ await requestMessageBuilder.ResponseWriter(responseResult.ContentStream, cancell
if (request.Method == HttpMethod.Head)
{
if (responseResult.Exception?.GetType().Equals(typeof(BucketNotFoundException)) == true ||
path?.ToList().Count == 1)
path.Length == 1)
responseResult.Exception = new BucketNotFoundException();

if (path?.ToList().Count > 1)
if (path.Length > 1)
{
var found = await minioClient
.BucketExistsAsync(new BucketExistsArgs().WithBucket(path.ToList()[0]), cancellationToken)
Expand All @@ -126,8 +126,6 @@ await requestMessageBuilder.ResponseWriter(responseResult.ContentStream, cancell
request.Method == HttpMethod.Get)
responseResult.Exception = new MissingObjectLockConfigurationException();
}

return responseResult;
}
catch (Exception ex) when (ex is not (OperationCanceledException or
ObjectNotFoundException))
Expand All @@ -141,6 +139,9 @@ await requestMessageBuilder.ResponseWriter(responseResult.ContentStream, cancell
responseResult = new ResponseResult(request, ex);
return responseResult;
}

minioClient.HandleIfErrorResponse(responseResult, errorHandlers, startTime);
return responseResult;
}

private static Task<ResponseResult> ExecuteWithRetry(this IMinioClient minioClient,
Expand Down Expand Up @@ -369,7 +370,7 @@ private static void HandleIfErrorResponse(this IMinioClient minioClient, Respons
minioClient.LogRequest(response.Request, response, (now - startTime).TotalMilliseconds);
}

if (response.Exception is null)
if (response.Exception is not null)
throw response.Exception;

if (handlers.Any())
Expand Down
Loading