Add Galaxy repository API and clients
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
using MxGateway.Server.Galaxy;
|
||||
|
||||
namespace MxGateway.IntegrationTests.Galaxy;
|
||||
|
||||
public sealed class GalaxyRepositoryLiveTests
|
||||
{
|
||||
[LiveGalaxyRepositoryFact]
|
||||
[Trait("Category", "LiveGalaxy")]
|
||||
public async Task TestConnection_AgainstZb_Succeeds()
|
||||
{
|
||||
GalaxyRepository repository = CreateRepository();
|
||||
|
||||
bool ok = await repository.TestConnectionAsync(CancellationToken.None);
|
||||
|
||||
Assert.True(ok, "TestConnectionAsync should return true against the ZB database.");
|
||||
}
|
||||
|
||||
[LiveGalaxyRepositoryFact]
|
||||
[Trait("Category", "LiveGalaxy")]
|
||||
public async Task GetLastDeployTime_AgainstZb_ReturnsTimestamp()
|
||||
{
|
||||
GalaxyRepository repository = CreateRepository();
|
||||
|
||||
DateTime? lastDeploy = await repository.GetLastDeployTimeAsync(CancellationToken.None);
|
||||
|
||||
Assert.NotNull(lastDeploy);
|
||||
}
|
||||
|
||||
[LiveGalaxyRepositoryFact]
|
||||
[Trait("Category", "LiveGalaxy")]
|
||||
public async Task GetHierarchy_AgainstZb_ReturnsObjects()
|
||||
{
|
||||
GalaxyRepository repository = CreateRepository();
|
||||
|
||||
List<GalaxyHierarchyRow> rows = await repository.GetHierarchyAsync(CancellationToken.None);
|
||||
|
||||
Assert.NotEmpty(rows);
|
||||
Assert.All(rows, row =>
|
||||
{
|
||||
Assert.True(row.GobjectId > 0);
|
||||
Assert.False(string.IsNullOrEmpty(row.TagName));
|
||||
Assert.False(string.IsNullOrEmpty(row.BrowseName));
|
||||
});
|
||||
}
|
||||
|
||||
[LiveGalaxyRepositoryFact]
|
||||
[Trait("Category", "LiveGalaxy")]
|
||||
public async Task GetAttributes_AgainstZb_ReturnsAtLeastOneAttribute()
|
||||
{
|
||||
GalaxyRepository repository = CreateRepository();
|
||||
|
||||
List<GalaxyAttributeRow> rows = await repository.GetAttributesAsync(CancellationToken.None);
|
||||
|
||||
Assert.NotEmpty(rows);
|
||||
Assert.All(rows, row =>
|
||||
{
|
||||
Assert.True(row.GobjectId > 0);
|
||||
Assert.False(string.IsNullOrEmpty(row.AttributeName));
|
||||
Assert.False(string.IsNullOrEmpty(row.FullTagReference));
|
||||
});
|
||||
}
|
||||
|
||||
private static GalaxyRepository CreateRepository() => new(new GalaxyRepositoryOptions
|
||||
{
|
||||
ConnectionString = LiveGalaxyRepositoryFactAttribute.ConnectionString,
|
||||
CommandTimeoutSeconds = 30,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
namespace MxGateway.IntegrationTests.Galaxy;
|
||||
|
||||
public sealed class LiveGalaxyRepositoryFactAttribute : FactAttribute
|
||||
{
|
||||
public const string EnableVariableName = "MXGATEWAY_RUN_LIVE_GALAXY_TESTS";
|
||||
public const string ConnectionStringVariableName = "MXGATEWAY_LIVE_GALAXY_CONN";
|
||||
|
||||
public LiveGalaxyRepositoryFactAttribute()
|
||||
{
|
||||
if (!Enabled)
|
||||
{
|
||||
Skip = $"Set {EnableVariableName}=1 to run live Galaxy Repository tests.";
|
||||
}
|
||||
}
|
||||
|
||||
public static bool Enabled =>
|
||||
string.Equals(
|
||||
Environment.GetEnvironmentVariable(EnableVariableName),
|
||||
"1",
|
||||
StringComparison.Ordinal);
|
||||
|
||||
public static string ConnectionString =>
|
||||
Environment.GetEnvironmentVariable(ConnectionStringVariableName)
|
||||
?? "Server=localhost;Database=ZB;Integrated Security=True;TrustServerCertificate=True;Encrypt=False;";
|
||||
}
|
||||
@@ -251,6 +251,7 @@ public sealed class WorkerLiveMxAccessSmokeTests(ITestOutputHelper output)
|
||||
new MxAccessGrpcRequestValidator(),
|
||||
mapper,
|
||||
eventStreamService,
|
||||
_metrics,
|
||||
_loggerFactory.CreateLogger<MxAccessGatewayService>());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user