Skip to content

Commit 07730d3

Browse files
committed
Another attempt at empty parameters in test
1 parent 3822542 commit 07730d3

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

tests-integration/Elastic.Assembler.IntegrationTests/AssembleFixture.cs

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,23 @@
1818

1919
namespace Elastic.Assembler.IntegrationTests;
2020

21+
public static partial class DistributedApplicationExtensions
22+
{
23+
/// <summary>
24+
/// Ensures all parameters in the application configuration have values set.
25+
/// </summary>
26+
public static TBuilder WithEmptyParameters<TBuilder>(this TBuilder builder)
27+
where TBuilder : IDistributedApplicationTestingBuilder
28+
{
29+
var parameters = builder.Resources.OfType<ParameterResource>().Where(p => !p.IsConnectionString).ToList();
30+
foreach (var parameter in parameters)
31+
builder.Configuration[$"Parameters:{parameter.Name}"] = string.Empty;
32+
33+
return builder;
34+
}
35+
}
36+
37+
2138
public class DocumentationFixture : IAsyncLifetime
2239
{
2340
public DistributedApplication DistributedApplication { get; private set; } = null!;
@@ -34,27 +51,12 @@ public async ValueTask InitializeAsync()
3451
options.DisableDashboard = true;
3552
options.AllowUnsecuredTransport = true;
3653
options.EnableResourceLogging = true;
37-
if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("CI")))
38-
{
39-
var config = new ConfigurationManager();
40-
config["Parameters:DocumentationElasticUrl"] = string.Empty;
41-
config["Parameters:DocumentationElasticApiKey"] = string.Empty;
42-
config["Parameters:LlmGatewayUrl"] = string.Empty;
43-
config["Parameters:LlmGatewayServiceAccountPath"] = string.Empty;
44-
settings.Configuration = config;
45-
}
4654
}
4755
);
56+
_ = builder.WithEmptyParameters();
4857
_ = builder.Services.AddElasticDocumentationLogging(LogLevel.Information);
4958
_ = builder.Services.AddLogging(c => c.AddXUnit());
5059
_ = builder.Services.AddLogging(c => c.AddInMemory());
51-
if (!string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("CI")))
52-
{
53-
_ = builder.AddParameter("LlmGatewayUrl", value: string.Empty);
54-
_ = builder.AddParameter("LlmGatewayServiceAccountPath", value: string.Empty);
55-
_ = builder.AddParameter("DocumentationElasticUrl", value: string.Empty);
56-
_ = builder.AddParameter("DocumentationElasticApiKey", value: string.Empty);
57-
}
5860

5961

6062
DistributedApplication = await builder.BuildAsync();

0 commit comments

Comments
 (0)