Skip to content

Commit c38c421

Browse files
committed
tests
1 parent e47dbe7 commit c38c421

File tree

1 file changed

+58
-10
lines changed

1 file changed

+58
-10
lines changed
Lines changed: 58 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
using System;
22
using System.IO;
33
using System.Threading.Tasks;
4+
using Amazon.S3;
45
using ManagedCode.Storage.Azure.Extensions;
56
using ManagedCode.Storage.Azure.Options;
7+
using ManagedCode.Storage.Core.Extensions;
68
using ManagedCode.Storage.FileSystem.Extensions;
79
using ManagedCode.Storage.FileSystem.Options;
10+
using ManagedCode.Storage.Aws.Extensions;
11+
using ManagedCode.Storage.Aws.Options;
812
using ManagedCode.Storage.Tests.Common.TestApp;
913
using Microsoft.AspNetCore.Mvc.Testing;
1014
using Microsoft.Extensions.Hosting;
1115
using Testcontainers.Azurite;
16+
using Testcontainers.LocalStack;
17+
using Google.Cloud.Storage.V1;
18+
using ManagedCode.Storage.Google.Extensions;
19+
using ManagedCode.Storage.Google.Options;
20+
using Testcontainers.FakeGcsServer;
1221
using Xunit;
1322

1423
namespace ManagedCode.Storage.Tests.Common;
@@ -17,45 +26,84 @@ namespace ManagedCode.Storage.Tests.Common;
1726
public class StorageTestApplication : WebApplicationFactory<HttpHostProgram>, ICollectionFixture<StorageTestApplication>
1827
{
1928
private readonly AzuriteContainer _azuriteContainer;
29+
private readonly LocalStackContainer _localStackContainer;
30+
private readonly FakeGcsServerContainer _gcpContainer;
2031

2132
public StorageTestApplication()
2233
{
23-
_azuriteContainer = new AzuriteBuilder().WithImage(ContainerImages.Azurite)
34+
_azuriteContainer = new AzuriteBuilder()
35+
.WithImage(ContainerImages.Azurite)
2436
.Build();
2537

26-
_azuriteContainer.StartAsync()
27-
.Wait();
38+
_localStackContainer = new LocalStackBuilder()
39+
.WithImage(ContainerImages.LocalStack)
40+
.Build();
41+
42+
_gcpContainer = new FakeGcsServerBuilder()
43+
.WithImage(ContainerImages.FakeGCSServer)
44+
.Build();
45+
46+
Task.WaitAll(
47+
_azuriteContainer.StartAsync(),
48+
_localStackContainer.StartAsync(),
49+
_gcpContainer.StartAsync()
50+
);
2851
}
2952

3053
protected override IHost CreateHost(IHostBuilder builder)
3154
{
3255
builder.ConfigureServices(services =>
3356
{
34-
#region Add FileSystemStorage
57+
services.AddStorageFactory();
3558

3659
services.AddFileSystemStorage(new FileSystemStorageOptions
3760
{
3861
BaseFolder = Path.Combine(Environment.CurrentDirectory, "managed-code-bucket")
3962
});
4063

41-
#endregion
42-
43-
#region Add AzureStorage
44-
4564
services.AddAzureStorage(new AzureStorageOptions
4665
{
4766
Container = "managed-code-bucket",
4867
ConnectionString = _azuriteContainer.GetConnectionString()
4968
});
5069

51-
#endregion
70+
services.AddGCPStorage(new GCPStorageOptions
71+
{
72+
BucketOptions = new BucketOptions
73+
{
74+
ProjectId = "api-project-0000000000000",
75+
Bucket = "managed-code-bucket"
76+
},
77+
StorageClientBuilder = new StorageClientBuilder
78+
{
79+
UnauthenticatedAccess = true,
80+
BaseUri = _gcpContainer.GetConnectionString()
81+
}
82+
});
83+
84+
85+
var config = new AmazonS3Config();
86+
config.ServiceURL = _localStackContainer.GetConnectionString();
87+
88+
services.AddAWSStorage(new AWSStorageOptions
89+
{
90+
PublicKey = "localkey",
91+
SecretKey = "localsecret",
92+
Bucket = "managed-code-bucket",
93+
OriginalOptions = config
94+
});
95+
5296
});
5397

5498
return base.CreateHost(builder);
5599
}
56100

57101
public override async ValueTask DisposeAsync()
58102
{
59-
await _azuriteContainer.DisposeAsync();
103+
await Task.WhenAll(
104+
_azuriteContainer.DisposeAsync().AsTask(),
105+
_localStackContainer.DisposeAsync().AsTask(),
106+
_gcpContainer.DisposeAsync().AsTask()
107+
);
60108
}
61109
}

0 commit comments

Comments
 (0)