Support DistributedApplicationTestingBuilder with IsPublishMode == true
- Dominant language
- C#
- Stars
- 6.3k
- Forks
- 991
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 196
Description
Trying to write a test that uses `DistributedApplicationTestingBuilder.CreateAsync` to test my publisher. In order to test my publisher against a sample app, I have:
```C#
using var builder = await DistributedApplicationTestingBuilder.CreateAsync();
builder.AddXunitLogging(Output);
builder.Services.AddSingleton(_ => NullPublishingActivityProgressReporter.Instance);
builder.Services.Configure("mypub", options =>
{
options.OutputPath = _tempOutputDir.FullName;
});
await using var app = await builder.BuildAsync();
await app.StartAsync();
var model = app.Services.GetRequiredService();
var publisher = app.Services.GetKeyedService("mypub");
Assert.NotNull(publisher);
await publisher.PublishAsync(model, default);
```
The issue is if I do `DistributedApplicationTestingBuilder.CreateAsync()`, it creates the DistributedApplication with `IsRunMode == true`. But I need to execute the AppHost in Publish mode.
As far I as can tell, there isn't a clean way to set this up. I can pass in `--publisher`, but that requires a publisher to be passed. And so when `DistributedApplicationTestingBuilder.CreateAsync` runs, it will run the `Main` method of the sample app, which will kick off a publish operation. But my test is also publishing concurrently. This creates problems since they are both publishing.
cc @captainsafia @mitchdenny
Contributor guide
Assessment
This issue has not been assessed yet.