part #2
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
using System;
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
using Microsoft.Extensions.Options;
|
||||
using StellaOps.AirGap.Importer.Versioning;
|
||||
using StellaOps.AirGap.Persistence.Postgres;
|
||||
using StellaOps.AirGap.Persistence.Postgres.Repositories;
|
||||
using StellaOps.Infrastructure.Postgres.Options;
|
||||
using StellaOps.TestKit;
|
||||
using Xunit;
|
||||
|
||||
namespace StellaOps.AirGap.Persistence.Tests;
|
||||
|
||||
[Collection(AirGapPostgresCollection.Name)]
|
||||
[Trait("Category", TestCategories.Integration)]
|
||||
[Trait("BlastRadius", TestCategories.BlastRadius.Persistence)]
|
||||
public sealed partial class PostgresBundleVersionStoreTests : IAsyncLifetime
|
||||
{
|
||||
private static readonly DateTimeOffset BaseCreatedAt =
|
||||
new(2025, 2, 1, 0, 0, 0, TimeSpan.Zero);
|
||||
|
||||
private static readonly DateTimeOffset BaseActivatedAt =
|
||||
new(2025, 2, 1, 0, 10, 0, TimeSpan.Zero);
|
||||
|
||||
private readonly AirGapPostgresFixture _fixture;
|
||||
private readonly PostgresBundleVersionStore _store;
|
||||
private readonly AirGapDataSource _dataSource;
|
||||
|
||||
public PostgresBundleVersionStoreTests(AirGapPostgresFixture fixture)
|
||||
{
|
||||
_fixture = fixture;
|
||||
var options = Options.Create(new PostgresOptions
|
||||
{
|
||||
ConnectionString = fixture.ConnectionString,
|
||||
SchemaName = fixture.SchemaName,
|
||||
AutoMigrate = false
|
||||
});
|
||||
|
||||
_dataSource = new AirGapDataSource(options, NullLogger<AirGapDataSource>.Instance);
|
||||
_store = new PostgresBundleVersionStore(_dataSource, NullLogger<PostgresBundleVersionStore>.Instance);
|
||||
}
|
||||
|
||||
public async ValueTask InitializeAsync()
|
||||
{
|
||||
await _fixture.TruncateAllTablesAsync();
|
||||
}
|
||||
|
||||
public async ValueTask DisposeAsync()
|
||||
{
|
||||
await _dataSource.DisposeAsync();
|
||||
}
|
||||
|
||||
private static BundleVersionRecord CreateRecord(
|
||||
string tenantId,
|
||||
string bundleType,
|
||||
int major,
|
||||
int minor,
|
||||
int patch,
|
||||
DateTimeOffset createdAt,
|
||||
DateTimeOffset activatedAt,
|
||||
string? prerelease = null,
|
||||
bool wasForceActivated = false,
|
||||
string? forceActivateReason = null)
|
||||
{
|
||||
var versionString = prerelease is null
|
||||
? $"{major}.{minor}.{patch}"
|
||||
: $"{major}.{minor}.{patch}-{prerelease}";
|
||||
|
||||
return new BundleVersionRecord(
|
||||
TenantId: tenantId,
|
||||
BundleType: bundleType,
|
||||
VersionString: versionString,
|
||||
Major: major,
|
||||
Minor: minor,
|
||||
Patch: patch,
|
||||
Prerelease: prerelease,
|
||||
BundleCreatedAt: createdAt,
|
||||
BundleDigest: $"sha256:bundle-{major}-{minor}-{patch}",
|
||||
ActivatedAt: activatedAt,
|
||||
WasForceActivated: wasForceActivated,
|
||||
ForceActivateReason: forceActivateReason);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user