|
1 | 1 | // Licensed to the .NET Foundation under one or more agreements.
|
2 | 2 | // The .NET Foundation licenses this file to you under the MIT license.
|
3 | 3 |
|
| 4 | +using System.Text.RegularExpressions; |
4 | 5 | using Aspire.Hosting;
|
5 | 6 | using Aspire.Hosting.Tests.Utils;
|
6 | 7 | using Aspire.TestUtilities;
|
@@ -78,23 +79,20 @@ await WaitForAllTextAsync(app,
|
78 | 79 | // Assert that HTTP triggers work correctly
|
79 | 80 | var response = await AppHostTests.CreateHttpClientWithResilience(app, "funcapp").GetAsync("/api/injected-resources");
|
80 | 81 |
|
81 |
| - |
82 |
| - var output = await response.Content.ReadAsStringAsync(); |
83 |
| - _testOutput.WriteLine($"[DEBUG] Response:\r\n{output}"); |
84 | 82 | /*
|
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 |
91 | 83 | */
|
| 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}"); |
92 | 90 | var expectedStrings = new string[]
|
93 | 91 | {
|
94 | 92 | "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" |
98 | 96 | };
|
99 | 97 | foreach (string s in expectedStrings)
|
100 | 98 | {
|
|
0 commit comments