fix: remove test
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
@echo off
|
||||
setlocal
|
||||
|
||||
set IMAGE=namdh861/mws-backend
|
||||
set CONTAINER=mws-backend
|
||||
set PORT=2000
|
||||
|
||||
echo [1/3] Building Docker image...
|
||||
docker build -t %IMAGE% .
|
||||
|
||||
if errorlevel 1 (
|
||||
echo Build failed.
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo [2/3] Stopping old container (if any)...
|
||||
docker rm -f %CONTAINER% >nul 2>&1
|
||||
|
||||
echo [3/3] Running container on port %PORT% with restart=always...
|
||||
docker run -d --name %CONTAINER% --restart always -p %PORT%:8080 %IMAGE%
|
||||
|
||||
if errorlevel 1 (
|
||||
echo Run failed.
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo Done. App running at http://localhost:%PORT%
|
||||
endlocal
|
||||
@@ -8,8 +8,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "domain", "domain\domain.csp
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "infrastructure", "infrastructure\infrastructure.csproj", "{FEFFBC10-B99E-4A56-9F32-6D925D192606}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "tests", "tests\tests.csproj", "{F69F8389-492D-4227-A6EC-2F41FC7FEBBE}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -68,18 +66,6 @@ Global
|
||||
{FEFFBC10-B99E-4A56-9F32-6D925D192606}.Release|x64.Build.0 = Release|Any CPU
|
||||
{FEFFBC10-B99E-4A56-9F32-6D925D192606}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{FEFFBC10-B99E-4A56-9F32-6D925D192606}.Release|x86.Build.0 = Release|Any CPU
|
||||
{F69F8389-492D-4227-A6EC-2F41FC7FEBBE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F69F8389-492D-4227-A6EC-2F41FC7FEBBE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F69F8389-492D-4227-A6EC-2F41FC7FEBBE}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{F69F8389-492D-4227-A6EC-2F41FC7FEBBE}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{F69F8389-492D-4227-A6EC-2F41FC7FEBBE}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{F69F8389-492D-4227-A6EC-2F41FC7FEBBE}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{F69F8389-492D-4227-A6EC-2F41FC7FEBBE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F69F8389-492D-4227-A6EC-2F41FC7FEBBE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F69F8389-492D-4227-A6EC-2F41FC7FEBBE}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{F69F8389-492D-4227-A6EC-2F41FC7FEBBE}.Release|x64.Build.0 = Release|Any CPU
|
||||
{F69F8389-492D-4227-A6EC-2F41FC7FEBBE}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{F69F8389-492D-4227-A6EC-2F41FC7FEBBE}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -1,134 +0,0 @@
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Moq;
|
||||
using mws.backend.dotnet.infrastructure.CloudFile;
|
||||
|
||||
namespace tests;
|
||||
|
||||
public class CloudFileDocumentContentStoreTests
|
||||
{
|
||||
private readonly Mock<ICloudFileHttpClient> _cfMock = new();
|
||||
private readonly Mock<ILogger<CloudFileDocumentContentStore>> _loggerMock = new();
|
||||
private readonly CloudFileDocumentContentStore _sut;
|
||||
|
||||
public CloudFileDocumentContentStoreTests()
|
||||
{
|
||||
_sut = new CloudFileDocumentContentStore(_cfMock.Object, _loggerMock.Object);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsureBucketAsync_CallsCorrectBucket()
|
||||
{
|
||||
var projectId = Guid.NewGuid();
|
||||
|
||||
await _sut.EnsureBucketAsync(projectId, CancellationToken.None);
|
||||
|
||||
_cfMock.Verify(c => c.EnsureBucketAsync($"mws-p-{projectId:N}", It.IsAny<CancellationToken>()), Times.Once);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task UploadAsync_BuildsCorrectBucketAndKey()
|
||||
{
|
||||
var projectId = Guid.NewGuid();
|
||||
var documentId = Guid.NewGuid();
|
||||
using var stream = new MemoryStream(new byte[] { 1, 2, 3 });
|
||||
|
||||
await _sut.UploadAsync(projectId, documentId, "text/html; charset=utf-8", stream, CancellationToken.None);
|
||||
|
||||
_cfMock.Verify(c => c.UploadAsync(
|
||||
$"mws-p-{projectId:N}",
|
||||
$"{documentId:N}.html",
|
||||
"text/html; charset=utf-8",
|
||||
It.IsAny<Stream>(),
|
||||
It.IsAny<CancellationToken>()), Times.Once);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task UploadAsync_ThrowsStorageUnavailableOnHttpRequestException()
|
||||
{
|
||||
var projectId = Guid.NewGuid();
|
||||
var documentId = Guid.NewGuid();
|
||||
using var stream = new MemoryStream(new byte[] { 1, 2, 3 });
|
||||
|
||||
_cfMock.Setup(c => c.UploadAsync(
|
||||
It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(),
|
||||
It.IsAny<Stream>(), It.IsAny<CancellationToken>()))
|
||||
.ThrowsAsync(new HttpRequestException("Connection refused"));
|
||||
|
||||
var ex = await Assert.ThrowsAsync<mws.backend.dotnet.application.Common.StorageUnavailableException>(
|
||||
() => _sut.UploadAsync(projectId, documentId, "text/html", stream, CancellationToken.None));
|
||||
|
||||
Assert.Contains("Cloud file upload failed", ex.Message);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task DownloadAsync_ReturnsStreamNullOnNotFound()
|
||||
{
|
||||
var projectId = Guid.NewGuid();
|
||||
var documentId = Guid.NewGuid();
|
||||
|
||||
_cfMock.Setup(c => c.DownloadAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<CancellationToken>()))
|
||||
.ReturnsAsync(Stream.Null);
|
||||
|
||||
var result = await _sut.DownloadAsync(projectId, documentId, CancellationToken.None);
|
||||
|
||||
Assert.Equal(Stream.Null, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task DownloadAsync_ThrowsStorageUnavailableOnHttpRequestException()
|
||||
{
|
||||
var projectId = Guid.NewGuid();
|
||||
var documentId = Guid.NewGuid();
|
||||
|
||||
_cfMock.Setup(c => c.DownloadAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<CancellationToken>()))
|
||||
.ThrowsAsync(new HttpRequestException("Connection refused"));
|
||||
|
||||
await Assert.ThrowsAsync<mws.backend.dotnet.application.Common.StorageUnavailableException>(
|
||||
() => _sut.DownloadAsync(projectId, documentId, CancellationToken.None));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task DeleteAsync_Swallows404Errors()
|
||||
{
|
||||
var projectId = Guid.NewGuid();
|
||||
var documentId = Guid.NewGuid();
|
||||
|
||||
// Should not throw
|
||||
await _sut.DeleteAsync(projectId, documentId, CancellationToken.None);
|
||||
|
||||
_cfMock.Verify(c => c.DeleteAsync(
|
||||
$"mws-p-{projectId:N}",
|
||||
$"{documentId:N}.html",
|
||||
It.IsAny<CancellationToken>()), Times.Once);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExistsAsync_ReturnsTrueWhenFileExists()
|
||||
{
|
||||
var projectId = Guid.NewGuid();
|
||||
var documentId = Guid.NewGuid();
|
||||
|
||||
_cfMock.Setup(c => c.ExistsAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<CancellationToken>()))
|
||||
.ReturnsAsync(true);
|
||||
|
||||
var result = await _sut.ExistsAsync(projectId, documentId, CancellationToken.None);
|
||||
|
||||
Assert.True(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExistsAsync_ReturnsFalseOnException()
|
||||
{
|
||||
var projectId = Guid.NewGuid();
|
||||
var documentId = Guid.NewGuid();
|
||||
|
||||
_cfMock.Setup(c => c.ExistsAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<CancellationToken>()))
|
||||
.ThrowsAsync(new HttpRequestException("Connection refused"));
|
||||
|
||||
var result = await _sut.ExistsAsync(projectId, documentId, CancellationToken.None);
|
||||
|
||||
Assert.False(result);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
namespace tests;
|
||||
|
||||
public class UnitTest1
|
||||
{
|
||||
[Fact]
|
||||
public void Test1()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.4" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
|
||||
<PackageReference Include="Moq" Version="4.20.72" />
|
||||
<PackageReference Include="xunit" Version="2.9.3" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.4" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Using Include="Xunit" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\infrastructure\infrastructure.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user