Move Alterations and MongoDb Test projects to Extensions.
This commit is contained in:
parent
044be5c09a
commit
0f6fbb8542
16
Elsa.sln
16
Elsa.sln
|
|
@ -87,7 +87,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "security", "security", "{59
|
|||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{B08B4E00-C2AB-48F3-8389-449F42AEF179}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "runtimes", "runtimes", "{58C59255-281C-4595-8732-808158F1DC6E}"
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_runtimes", "_runtimes", "{58C59255-281C-4595-8732-808158F1DC6E}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.Mediator", "src\common\Elsa.Mediator\Elsa.Mediator.csproj", "{28818676-F6AF-4203-8B65-BD33A50CB9A2}"
|
||||
EndProject
|
||||
|
|
@ -110,8 +110,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "_build", "build\_build.cspr
|
|||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scripts", "scripts", "{C80C8231-D35C-4ACC-9ED6-9F3DB221535E}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.Alterations.IntegrationTests", "test\integration\Elsa.Alterations.IntegrationTests\Elsa.Alterations.IntegrationTests.csproj", "{F50336DA-42D1-4DD1-A107-67AFEB8A33EE}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "hosting", "hosting", "{A516931E-EDBB-4FC3-BB94-1BB824D5BC61}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.Hosting.Management", "src\modules\Elsa.Hosting.Management\Elsa.Hosting.Management.csproj", "{BBCE36D1-6767-4ED1-B3E8-84D2567A962A}"
|
||||
|
|
@ -129,8 +127,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "performance", "performance"
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.Workflows.PerformanceTests", "test\performance\Elsa.Workflows.PerformanceTests\Elsa.Workflows.PerformanceTests.csproj", "{90CD37A9-C866-4D90-A3B1-8C87F53B845E}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.MongoDb.UnitTests", "test\unit\Elsa.MongoDb.UnitTests\Elsa.MongoDb.UnitTests.csproj", "{56CAA9F2-1882-4EFA-BAC0-9C3D804553F1}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.Workflows.Runtime.Distributed", "src\modules\Elsa.Workflows.Runtime.Distributed\Elsa.Workflows.Runtime.Distributed.csproj", "{0D4A88A1-8AEE-49ED-BC2E-ED68C96F60AD}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.Testing.Shared", "src\common\Elsa.Testing.Shared\Elsa.Testing.Shared.csproj", "{5CBCBEA4-6038-48CA-B45D-C1D0F6B4ACA4}"
|
||||
|
|
@ -346,10 +342,6 @@ Global
|
|||
{29638A67-E79F-44FE-AC05-DA499EBA929E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{99F2B1DA-2F69-4D70-A2A3-AC985AD91EC4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{99F2B1DA-2F69-4D70-A2A3-AC985AD91EC4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F50336DA-42D1-4DD1-A107-67AFEB8A33EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F50336DA-42D1-4DD1-A107-67AFEB8A33EE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F50336DA-42D1-4DD1-A107-67AFEB8A33EE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F50336DA-42D1-4DD1-A107-67AFEB8A33EE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{BBCE36D1-6767-4ED1-B3E8-84D2567A962A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{BBCE36D1-6767-4ED1-B3E8-84D2567A962A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BBCE36D1-6767-4ED1-B3E8-84D2567A962A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
|
|
@ -370,10 +362,6 @@ Global
|
|||
{90CD37A9-C866-4D90-A3B1-8C87F53B845E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{90CD37A9-C866-4D90-A3B1-8C87F53B845E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{90CD37A9-C866-4D90-A3B1-8C87F53B845E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{56CAA9F2-1882-4EFA-BAC0-9C3D804553F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{56CAA9F2-1882-4EFA-BAC0-9C3D804553F1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{56CAA9F2-1882-4EFA-BAC0-9C3D804553F1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{56CAA9F2-1882-4EFA-BAC0-9C3D804553F1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{0D4A88A1-8AEE-49ED-BC2E-ED68C96F60AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0D4A88A1-8AEE-49ED-BC2E-ED68C96F60AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0D4A88A1-8AEE-49ED-BC2E-ED68C96F60AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
|
|
@ -502,7 +490,6 @@ Global
|
|||
{28818676-F6AF-4203-8B65-BD33A50CB9A2} = {C6658DE0-2B2F-47F0-BB61-2CA66D435C09}
|
||||
{DC9CCAD0-7363-4691-B964-FF5B3AEA3F95} = {18453B51-25EB-4317-A4B3-B10518252E92}
|
||||
{29638A67-E79F-44FE-AC05-DA499EBA929E} = {2F3E1026-5054-4E1F-899B-F1A7F70F9912}
|
||||
{F50336DA-42D1-4DD1-A107-67AFEB8A33EE} = {1B8D5897-902E-4632-8698-E89CAF3DDF54}
|
||||
{A516931E-EDBB-4FC3-BB94-1BB824D5BC61} = {5BA4A8FA-F7F4-45B3-AEC8-8886D35AAC79}
|
||||
{BBCE36D1-6767-4ED1-B3E8-84D2567A962A} = {A516931E-EDBB-4FC3-BB94-1BB824D5BC61}
|
||||
{73BBB1E3-AEEC-44E8-83D7-6DD9CD687FE3} = {5BA4A8FA-F7F4-45B3-AEC8-8886D35AAC79}
|
||||
|
|
@ -510,7 +497,6 @@ Global
|
|||
{34BC9836-681D-43A5-BC39-E4FEE17FC528} = {08B41FFA-CEE3-46A7-B5C0-3EB65D37A16C}
|
||||
{CBB515F3-A0EF-43B5-A907-FD4E652DD66E} = {90031D64-CA0F-46D0-9AF4-8DC023A5FFCD}
|
||||
{90CD37A9-C866-4D90-A3B1-8C87F53B845E} = {CBB515F3-A0EF-43B5-A907-FD4E652DD66E}
|
||||
{56CAA9F2-1882-4EFA-BAC0-9C3D804553F1} = {18453B51-25EB-4317-A4B3-B10518252E92}
|
||||
{0D4A88A1-8AEE-49ED-BC2E-ED68C96F60AD} = {58C59255-281C-4595-8732-808158F1DC6E}
|
||||
{5CBCBEA4-6038-48CA-B45D-C1D0F6B4ACA4} = {C6658DE0-2B2F-47F0-BB61-2CA66D435C09}
|
||||
{94A61AD7-2A2B-40DB-81F3-C59D596958A8} = {C6658DE0-2B2F-47F0-BB61-2CA66D435C09}
|
||||
|
|
|
|||
|
|
@ -1,22 +0,0 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\src\common\Elsa.Testing.Shared.Integration\Elsa.Testing.Shared.Integration.csproj" />
|
||||
<ProjectReference Include="..\..\..\src\modules\Elsa.Alterations\Elsa.Alterations.csproj" />
|
||||
<ProjectReference Include="..\..\..\src\modules\Elsa.Workflows.Runtime\Elsa.Workflows.Runtime.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Workflows\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Workflows\version-1.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Workflows\version-2.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
@ -1,73 +0,0 @@
|
|||
using Elsa.Alterations.AlterationTypes;
|
||||
using Elsa.Alterations.Core.Contracts;
|
||||
using Elsa.Alterations.Extensions;
|
||||
using Elsa.Common.Models;
|
||||
using Elsa.Extensions;
|
||||
using Elsa.Testing.Shared;
|
||||
using Elsa.Workflows.Management;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace Elsa.Alterations.IntegrationTests;
|
||||
|
||||
/// <summary>
|
||||
/// Contains tests for migration.
|
||||
/// </summary>
|
||||
public class MigrationTests
|
||||
{
|
||||
private readonly CapturingTextWriter _capturingTextWriter = new();
|
||||
private readonly IServiceProvider _services;
|
||||
private readonly IAlterationRunner _alterationRunner;
|
||||
private readonly IWorkflowInstanceStore _workflowInstanceStore;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MigrationTests"/> class.
|
||||
/// </summary>
|
||||
public MigrationTests(ITestOutputHelper testOutputHelper)
|
||||
{
|
||||
_services = new TestApplicationBuilder(testOutputHelper)
|
||||
.WithCapturingTextWriter(_capturingTextWriter)
|
||||
.ConfigureElsa(elsa => elsa.UseAlterations())
|
||||
.Build();
|
||||
_alterationRunner = _services.GetRequiredService<IAlterationRunner>();
|
||||
_workflowInstanceStore = _services.GetRequiredService<IWorkflowInstanceStore>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method tests the migration from version 1 to version 2.
|
||||
/// </summary>
|
||||
[Fact(DisplayName = "Migrating from version 1 to 2 succeeds")]
|
||||
public async Task Test1()
|
||||
{
|
||||
// Populate registries.
|
||||
await _services.PopulateRegistriesAsync();
|
||||
|
||||
// Import workflows.
|
||||
await _services.ImportWorkflowDefinitionAsync("Workflows/version-1.json");
|
||||
await _services.ImportWorkflowDefinitionAsync("Workflows/version-2.json");
|
||||
|
||||
// Run version 1 workflow.
|
||||
var workflowState = await _services.RunWorkflowUntilEndAsync("my-workflow", versionOptions: VersionOptions.SpecificVersion(1));
|
||||
|
||||
// Migrate to version 2.
|
||||
var alterations = new IAlteration[]
|
||||
{
|
||||
new Migrate
|
||||
{
|
||||
TargetVersion = 2
|
||||
}
|
||||
};
|
||||
var instanceIds = new[]
|
||||
{
|
||||
workflowState.Id
|
||||
};
|
||||
var migrationResult = await _alterationRunner.RunAsync(instanceIds, alterations);
|
||||
|
||||
// Assert success.
|
||||
Assert.True(migrationResult.All(x => x.IsSuccessful));
|
||||
|
||||
// Assert that the workflow instance is now at version 2.
|
||||
var workflowState2 = await _workflowInstanceStore.FindAsync(workflowState.Id);
|
||||
Assert.Equal(2, workflowState2!.Version);
|
||||
}
|
||||
}
|
||||
|
|
@ -1 +0,0 @@
|
|||
global using Xunit;
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
{
|
||||
"id": "b760f121e7dc5dae",
|
||||
"definitionId": "my-workflow",
|
||||
"name": "Version 1",
|
||||
"version": 1,
|
||||
"toolVersion": "3.0.0.0",
|
||||
"root": {
|
||||
"type": "Elsa.Flowchart",
|
||||
"version": 1,
|
||||
"id": "52ae1d65f7896a9e",
|
||||
"nodeId": "Workflow1:52ae1d65f7896a9e",
|
||||
"activities": [
|
||||
{
|
||||
"text": {
|
||||
"typeName": "String",
|
||||
"expression": {
|
||||
"type": "Literal",
|
||||
"value": "Version 1"
|
||||
}
|
||||
},
|
||||
"id": "3a1ab61a351fe232",
|
||||
"nodeId": "Workflow1:52ae1d65f7896a9e:3a1ab61a351fe232",
|
||||
"name": "WriteLine1",
|
||||
"type": "Elsa.WriteLine",
|
||||
"metadata": {
|
||||
"designer": {
|
||||
"position": {
|
||||
"x": -121.796875,
|
||||
"y": 272
|
||||
},
|
||||
"size": {
|
||||
"width": 139.296875,
|
||||
"height": 50
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"connections": []
|
||||
}
|
||||
}
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
{
|
||||
"id": "4aca2e3aa79475d3",
|
||||
"definitionId": "my-workflow",
|
||||
"name": "Version 2",
|
||||
"version": 2,
|
||||
"toolVersion": "3.0.0.0",
|
||||
"root": {
|
||||
"type": "Elsa.Flowchart",
|
||||
"version": 1,
|
||||
"id": "52ae1d65f7896a9e",
|
||||
"nodeId": "Workflow1:52ae1d65f7896a9e",
|
||||
"activities": [
|
||||
{
|
||||
"text": {
|
||||
"typeName": "String",
|
||||
"expression": {
|
||||
"type": "Literal",
|
||||
"value": "Version 2"
|
||||
}
|
||||
},
|
||||
"id": "3a1ab61a351fe232",
|
||||
"nodeId": "Workflow1:52ae1d65f7896a9e:3a1ab61a351fe232",
|
||||
"name": "WriteLine1",
|
||||
"type": "Elsa.WriteLine",
|
||||
"metadata": {
|
||||
"designer": {
|
||||
"position": {
|
||||
"x": -121.796875,
|
||||
"y": 272
|
||||
},
|
||||
"size": {
|
||||
"width": 139.296875,
|
||||
"height": 50
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"connections": []
|
||||
}
|
||||
}
|
||||
|
|
@ -5,16 +5,16 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Proto.Persistence.Sqlite" />
|
||||
<PackageReference Include="Elsa.Http" />
|
||||
<PackageReference Include="Elsa.Scripting.JavaScript" />
|
||||
<PackageReference Include="Elsa.Scheduling" />
|
||||
<PackageReference Include="Elsa.WorkflowProviders.BlobStorage" />
|
||||
<PackageReference Include="Proto.Persistence.Sqlite" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\src\common\Elsa.Testing.Shared.Integration\Elsa.Testing.Shared.Integration.csproj" />
|
||||
<ProjectReference Include="..\..\..\src\modules\Elsa.Http\Elsa.Http.csproj" />
|
||||
<ProjectReference Include="..\..\..\src\modules\Elsa.JavaScript\Elsa.JavaScript.csproj" />
|
||||
<ProjectReference Include="..\..\..\src\modules\Elsa.Workflows.Runtime.ProtoActor\Elsa.Workflows.Runtime.ProtoActor.csproj" />
|
||||
<ProjectReference Include="..\..\..\src\modules\Elsa.Scheduling\Elsa.Scheduling.csproj" />
|
||||
<ProjectReference Include="..\..\..\src\modules\Elsa.WorkflowProviders.BlobStorage\Elsa.WorkflowProviders.BlobStorage.csproj" />
|
||||
<ProjectReference Include="..\..\..\src\modules\Elsa.Workflows.Api\Elsa.Workflows.Api.csproj" />
|
||||
<ProjectReference Include="..\..\..\src\modules\Elsa.Workflows.Runtime\Elsa.Workflows.Runtime.csproj" />
|
||||
</ItemGroup>
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\src\modules\Elsa.MongoDb\Elsa.MongoDb.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
using Elsa.Common.Multitenancy;
|
||||
using Elsa.KeyValues.Entities;
|
||||
using Elsa.MongoDb.Common;
|
||||
using Elsa.MongoDb.Modules.Runtime;
|
||||
using MongoDB.Driver;
|
||||
using NSubstitute;
|
||||
|
||||
namespace Elsa.MongoDb.UnitTests;
|
||||
|
||||
public class MongoKeyValueStoreTests
|
||||
{
|
||||
private readonly MongoDbStore<SerializedKeyValuePair> _mongoDbStore;
|
||||
|
||||
public MongoKeyValueStoreTests()
|
||||
{
|
||||
var mongoCollectionMock = Substitute.For<IMongoCollection<SerializedKeyValuePair>>();
|
||||
var tenantAccessorMock = Substitute.For<ITenantAccessor>();
|
||||
mongoCollectionMock.FindOneAndReplaceAsync(
|
||||
Arg.Any<FilterDefinition<SerializedKeyValuePair>>(),
|
||||
Arg.Any<SerializedKeyValuePair>(),
|
||||
Arg.Any<FindOneAndReplaceOptions<SerializedKeyValuePair>>()
|
||||
)
|
||||
.Returns(new SerializedKeyValuePair());
|
||||
_mongoDbStore = new MongoDbStore<SerializedKeyValuePair>(mongoCollectionMock, tenantAccessorMock);
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "When saving a SerializedKeyValuePair document, don't throw an exception of missing ID property")]
|
||||
public async Task SaveAsync_WithSerializedKeyValuePairDocument_DoesNotThrowException()
|
||||
{
|
||||
var mongoKeyValueStore = new MongoKeyValueStore(_mongoDbStore);
|
||||
var keyValuePair = new SerializedKeyValuePair();
|
||||
|
||||
var exception = await Record.ExceptionAsync(
|
||||
async () => await mongoKeyValueStore.SaveAsync(keyValuePair, default));
|
||||
|
||||
Assert.Null(exception);
|
||||
}
|
||||
}
|
||||
|
|
@ -1 +0,0 @@
|
|||
global using Xunit;
|
||||
Loading…
Reference in a new issue