74ddd95a05
ci / backend (push) Failing after 0s
ci / static (push) Failing after 6s
ci / backend (pull_request) Failing after 1s
ci / static (pull_request) Failing after 7s
Build & Test with Secrets / build (pull_request) Failing after 1s
ci / frontend (push) Failing after 48s
Build & Test with Secrets / security-scan (pull_request) Successful in 5s
Build & Test with Secrets / frontend (pull_request) Failing after 1m23s
ci / frontend (pull_request) Failing after 1m32s
Build & Test with Secrets / notification (pull_request) Failing after 2s
25 lines
909 B
C#
25 lines
909 B
C#
using System.Text.Json;
|
|
|
|
namespace KArtSell.Integration.Tests;
|
|
|
|
internal static class TestDatabaseConnection
|
|
{
|
|
public static string GetConnectionString()
|
|
{
|
|
var path = Path.Combine(AppContext.BaseDirectory, "appsettings.Development.json");
|
|
if (!File.Exists(path))
|
|
throw new InvalidOperationException($"Integration test settings are required: {path}");
|
|
|
|
using var document = JsonDocument.Parse(File.ReadAllText(path));
|
|
if (!document.RootElement.TryGetProperty("ConnectionStrings", out var connectionStrings) ||
|
|
!connectionStrings.TryGetProperty("Postgres", out var postgres) ||
|
|
string.IsNullOrWhiteSpace(postgres.GetString()))
|
|
{
|
|
throw new InvalidOperationException(
|
|
"ConnectionStrings:Postgres is required in appsettings.Development.json.");
|
|
}
|
|
|
|
return postgres.GetString()!;
|
|
}
|
|
}
|