Skip to content

Commit

Permalink
Update MinioTests.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
ANcpLua authored Jan 16, 2025
1 parent 21bf852 commit f0c8d29
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions Tests/MinioTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Contract.Logger;
using Contract.Logger;
using FluentAssertions;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
Expand All @@ -15,17 +15,17 @@ public class MinioTests
public async Task Setup()
{
var configBuilder = new ConfigurationBuilder()
.AddJsonFile("service-appsettings.json")
.AddEnvironmentVariables();
.AddJsonFile("service-appsettings.json")
.AddEnvironmentVariables();

_configuration = configBuilder.Build();

_minioClient = new MinioClient()
.WithEndpoint(_configuration["MinIO:Endpoint"] ?? "localhost:9000")
.WithCredentials(
_configuration["MinIO:AccessKey"],
_configuration["MinIO:SecretKey"])
.Build();
.WithEndpoint(_configuration["MinIO:Endpoint"] ?? "localhost:9000")
.WithCredentials(
_configuration["MinIO:AccessKey"],
_configuration["MinIO:SecretKey"])
.Build();

var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole());
_logger = new OperationLogger(
Expand Down Expand Up @@ -66,11 +66,11 @@ public async Task UploadFile_ToMinio_Succeeds()
// Arrange
await using var fileStream = File.OpenRead(_testFilePath);
var putObjectArgs = new PutObjectArgs()
.WithBucket(TestBucket)
.WithObject(TestFileName)
.WithStreamData(fileStream)
.WithObjectSize(fileStream.Length)
.WithContentType("application/pdf");
.WithBucket(TestBucket)
.WithObject(TestFileName)
.WithStreamData(fileStream)
.WithObjectSize(fileStream.Length)
.WithContentType("application/pdf");

// Act
await _minioClient.PutObjectAsync(putObjectArgs);
Expand Down Expand Up @@ -98,13 +98,13 @@ public async Task GetFile_FromMinio_Succeeds()
using var memoryStream = new MemoryStream();

var getObjectArgs = new GetObjectArgs()
.WithBucket(TestBucket)
.WithObject(TestFileName)
.WithCallbackStream(stream =>
{
stream.CopyTo(memoryStream);
memoryStream.Position = 0;
});
.WithBucket(TestBucket)
.WithObject(TestFileName)
.WithCallbackStream(stream =>
{
stream.CopyTo(memoryStream);
memoryStream.Position = 0;
});

// Act
await _minioClient.GetObjectAsync(getObjectArgs);
Expand All @@ -127,8 +127,8 @@ public async Task DeleteFile_FromMinio_Succeeds()
{
// Arrange
var removeObjectArgs = new RemoveObjectArgs()
.WithBucket(TestBucket)
.WithObject(TestFileName);
.WithBucket(TestBucket)
.WithObject(TestFileName);

// Act
await _minioClient.RemoveObjectAsync(removeObjectArgs);
Expand Down

0 comments on commit f0c8d29

Please sign in to comment.