Skip to content

Commit

Permalink
[tests] ManifestUtils.GetManifestWithBicep: generate in a temporary path
Browse files Browse the repository at this point in the history
Avoid interfering with other tests by generating the bicep files in
per-test temporyary paths.

Issue: #5113
  • Loading branch information
radical committed Aug 5, 2024
1 parent 419437d commit f92bd77
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tests/Aspire.Hosting.Tests/Utils/ManifestUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,20 @@ public static async Task<JsonNode[]> GetManifests(IResource[] resources)

public static async Task<(JsonNode ManifestNode, string BicepText)> GetManifestWithBicep(IResource resource)
{
var manifestNode = await GetManifest(resource);
string manifestDir = Directory.CreateTempSubdirectory(resource.Name).FullName;
var manifestNode = await GetManifest(resource, manifestDir);

if (!manifestNode.AsObject().TryGetPropertyValue("path", out var pathNode))
{
throw new ArgumentException("Specified resource does not contain a path property.", nameof(resource));
}

if (pathNode?.ToString() is not { } path || !File.Exists(path))
if (pathNode?.ToString() is not { } path || !File.Exists(Path.Combine(manifestDir, path)))
{
throw new ArgumentException("Path node in resource is null, empty, or does not exist.", nameof(resource));
}

var bicepText = await File.ReadAllTextAsync(path);
var bicepText = await File.ReadAllTextAsync(Path.Combine(manifestDir, path));
return (manifestNode, bicepText);
}
}

0 comments on commit f92bd77

Please sign in to comment.