stabilizaiton work - projects rework for maintenanceability and ui livening

This commit is contained in:
master
2026-02-03 23:40:04 +02:00
parent 074ce117ba
commit 557feefdc3
3305 changed files with 186813 additions and 107843 deletions

View File

@@ -0,0 +1,126 @@
// Copyright (c) StellaOps. All rights reserved.
// Licensed under BUSL-1.1. See LICENSE in the project root.
using StellaOps.Platform.WebService.Options;
using StellaOps.Platform.WebService.Services;
using StellaOps.TestKit;
using Xunit;
namespace StellaOps.Platform.WebService.Tests;
public sealed class SetupStateDetectorTests
{
private readonly SetupStateDetector _detector = new();
[Trait("Category", TestCategories.Unit)]
[Fact]
public void Detect_NoPostgresConnectionString_ReturnsNull()
{
var storage = new PlatformStorageOptions { PostgresConnectionString = null };
var dbSettings = new Dictionary<string, string>();
var result = _detector.Detect(storage, dbSettings);
Assert.Null(result);
}
[Trait("Category", TestCategories.Unit)]
[Fact]
public void Detect_EmptyPostgresConnectionString_ReturnsNull()
{
var storage = new PlatformStorageOptions { PostgresConnectionString = " " };
var dbSettings = new Dictionary<string, string>();
var result = _detector.Detect(storage, dbSettings);
Assert.Null(result);
}
[Trait("Category", TestCategories.Unit)]
[Fact]
public void Detect_FreshDbNoKeys_ReturnsNull()
{
var storage = new PlatformStorageOptions
{
PostgresConnectionString = "Host=localhost;Database=stella"
};
var dbSettings = new Dictionary<string, string>();
var result = _detector.Detect(storage, dbSettings);
Assert.Null(result);
}
[Trait("Category", TestCategories.Unit)]
[Fact]
public void Detect_SetupCompleteTrue_ReturnsComplete()
{
var storage = new PlatformStorageOptions
{
PostgresConnectionString = "Host=localhost;Database=stella"
};
var dbSettings = new Dictionary<string, string>
{
[SetupStateDetector.SetupCompleteKey] = "true"
};
var result = _detector.Detect(storage, dbSettings);
Assert.Equal("complete", result);
}
[Trait("Category", TestCategories.Unit)]
[Fact]
public void Detect_SetupCompleteTrueCaseInsensitive_ReturnsComplete()
{
var storage = new PlatformStorageOptions
{
PostgresConnectionString = "Host=localhost;Database=stella"
};
var dbSettings = new Dictionary<string, string>
{
[SetupStateDetector.SetupCompleteKey] = "True"
};
var result = _detector.Detect(storage, dbSettings);
Assert.Equal("complete", result);
}
[Trait("Category", TestCategories.Unit)]
[Fact]
public void Detect_SetupCompleteStepId_ReturnsStepId()
{
var storage = new PlatformStorageOptions
{
PostgresConnectionString = "Host=localhost;Database=stella"
};
var dbSettings = new Dictionary<string, string>
{
[SetupStateDetector.SetupCompleteKey] = "migrations"
};
var result = _detector.Detect(storage, dbSettings);
Assert.Equal("migrations", result);
}
[Trait("Category", TestCategories.Unit)]
[Fact]
public void Detect_ExistingDeploymentNoSetupCompleteKey_ReturnsComplete()
{
var storage = new PlatformStorageOptions
{
PostgresConnectionString = "Host=localhost;Database=stella"
};
var dbSettings = new Dictionary<string, string>
{
["ApiBaseUrls:scanner"] = "https://scanner.local",
["ClientId"] = "stella-ops-ui"
};
var result = _detector.Detect(storage, dbSettings);
Assert.Equal("complete", result);
}
}