-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure all integration have at least one test for manifest #115
Comments
How should we handle integrations that aren't for deployment, like the Node.js extensions or Static Web Apps? Do we want to validate that they generate nothing? |
I'm not sure about those and I did not see any test about the specific resources in I looked at Node.js extensions and did not see any checking about that |
That's a very good point, I'll add an issue tracking it. |
@aaronpowell public sealed class ManifestUtils
{
public static async Task<JsonNode> GetManifest(IResource resource, string? manifestDirectory = null)
{
var node = await GetManifestOrNull(resource, manifestDirectory);
Assert.NotNull(node);
return node;
}
public static async Task<JsonNode?> GetManifestOrNull(IResource resource, string? manifestDirectory = null)
{
manifestDirectory ??= Environment.CurrentDirectory;
using var ms = new MemoryStream();
var writer = new Utf8JsonWriter(ms);
var executionContext = new DistributedApplicationExecutionContext(DistributedApplicationOperation.Publish);
writer.WriteStartObject();
var context = new ManifestPublishingContext(executionContext, Path.Combine(manifestDirectory, "manifest.json"), writer);
await WriteResourceAsync(context, resource);
writer.WriteEndObject();
writer.Flush();
ms.Position = 0;
var obj = JsonNode.Parse(ms);
Assert.NotNull(obj);
var resourceNode = obj[resource.Name];
return resourceNode;
}
[UnsafeAccessor(UnsafeAccessorKind.Method, Name = "WriteResourceAsync")]
private static extern Task WriteResourceAsync(ManifestPublishingContext context, IResource resource);
} The only thing we should consider is |
That's probably the safest approach. While yes, using |
Example in aspire repo:
https://github.com/dotnet/aspire/blob/4c91f09e9c7f84e73eca6932f550475309155abd/tests/Aspire.Hosting.Redis.Tests/AddRedisTests.cs#L96-L120
We need
ManifestUtils
to generate manifest file.The text was updated successfully, but these errors were encountered: