Skip to content

Commit 5b5eb72

Browse files
committed
fixup! Tests
1 parent d2bcc55 commit 5b5eb72

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

tests/Aspire.Playground.Tests/ProjectSpecificTests.cs

+10-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.Text.RegularExpressions;
45
using Aspire.Hosting;
56
using Aspire.Hosting.Tests.Utils;
67
using Aspire.TestUtilities;
@@ -78,23 +79,20 @@ await WaitForAllTextAsync(app,
7879
// Assert that HTTP triggers work correctly
7980
var response = await AppHostTests.CreateHttpClientWithResilience(app, "funcapp").GetAsync("/api/injected-resources");
8081

81-
82-
var output = await response.Content.ReadAsStringAsync();
83-
_testOutput.WriteLine($"[DEBUG] Response:\r\n{output}");
8482
/*
85-
The output is expected to look something like this:
86-
87-
Aspire-injected EventHubProducerClient namespace: localhost
88-
Aspire-injected QueueServiceClient URI: http://127.0.0.1:62661/devstoreaccount1
89-
Aspire-injected BlobServiceClient URI: http://127.0.0.1:62666/devstoreaccount1
90-
Aspire-injected BlobContainerClient URI: http://127.0.0.1:62666/devstoreaccount1/myblobcontainer
9183
*/
84+
// The output contains multiple text lines.
85+
// There are some URLs which contain port number, but the port numbers may vary, so we replace those for test validation.
86+
var output = await response.Content.ReadAsStringAsync();
87+
output = Regex.Replace(output, pattern: @"(?<=http:\/\/127\.0\.0\.1:)\d+", replacement: "*");
88+
89+
_testOutput.WriteLine($"[DEBUG] Response:\r\n{output}");
9290
var expectedStrings = new string[]
9391
{
9492
"Aspire-injected EventHubProducerClient namespace: localhost",
95-
"Aspire-injected QueueServiceClient URI: http://127.0.0.1:62661/devstoreaccount1",
96-
"Aspire-injected BlobServiceClient URI: http://127.0.0.1:62666/devstoreaccount1",
97-
"Aspire-injected BlobContainerClient URI: http://127.0.0.1:62666/devstoreaccount1/myblobcontainer"
93+
"Aspire-injected QueueServiceClient URI: http://127.0.0.1:*/devstoreaccount1",
94+
"Aspire-injected BlobServiceClient URI: http://127.0.0.1:*/devstoreaccount1",
95+
"Aspire-injected BlobContainerClient URI: http://127.0.0.1:*/devstoreaccount1/myblobcontainer"
9896
};
9997
foreach (string s in expectedStrings)
10098
{

0 commit comments

Comments
 (0)