File tree Expand file tree Collapse file tree 4 files changed +56
-0
lines changed Expand file tree Collapse file tree 4 files changed +56
-0
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,7 @@ public static IResourceBuilder<AdminerContainerResource> AddAdminer(this IDistri
5151 . WithImage ( AdminerContainerImageTags . Image , AdminerContainerImageTags . Tag )
5252 . WithImageRegistry ( AdminerContainerImageTags . Registry )
5353 . WithHttpEndpoint ( targetPort : 8080 , port : port , name : AdminerContainerResource . PrimaryEndpointName )
54+ . WithUrlForEndpoint ( AdminerContainerResource . PrimaryEndpointName , e => e . DisplayText = "Adminer Dashboard" )
5455 . ExcludeFromManifest ( ) ;
5556
5657 var assembly = Assembly . GetExecutingAssembly ( ) ;
Original file line number Diff line number Diff line change @@ -80,6 +80,7 @@ public static IResourceBuilder<DbGateContainerResource> AddDbGate(this IDistribu
8080 . WithImage ( DbGateContainerImageTags . Image , DbGateContainerImageTags . Tag )
8181 . WithImageRegistry ( DbGateContainerImageTags . Registry )
8282 . WithHttpEndpoint ( targetPort : 3000 , port : port , name : DbGateContainerResource . PrimaryEndpointName )
83+ . WithUrlForEndpoint ( DbGateContainerResource . PrimaryEndpointName , e => e . DisplayText = "DbGate Dashboard" )
8384 . ExcludeFromManifest ( ) ;
8485
8586 return dbGateContainerBuilder ;
Original file line number Diff line number Diff line change 11using System . Net . Sockets ;
22using System . Text . Json ;
3+ using Aspire . Components . Common . Tests ;
34using Aspire . Hosting ;
5+ using Aspire . Hosting . Utils ;
46
57namespace CommunityToolkit . Aspire . Hosting . Adminer . Tests ;
68public class AddAdminerTests
@@ -208,4 +210,29 @@ public void WithAdminerShouldShouldAddOneAdminerResourceForMultipleDatabaseTypes
208210 var containerResource = Assert . Single ( appModel . Resources . OfType < AdminerContainerResource > ( ) ) ;
209211 Assert . Equal ( "postgres1-adminer" , containerResource . Name ) ;
210212 }
213+
214+ [ Fact ]
215+ [ RequiresDocker ]
216+ public async Task AddAdminerWithDefaultsAddsUrlAnnotations ( )
217+ {
218+ using var builder = TestDistributedApplicationBuilder . Create ( ) ;
219+
220+ var adminer = builder . AddAdminer ( "adminer" ) ;
221+
222+ var tcs = new TaskCompletionSource ( TaskCreationOptions . RunContinuationsAsynchronously ) ;
223+ builder . Eventing . Subscribe < AfterEndpointsAllocatedEvent > ( ( e , ct ) =>
224+ {
225+ tcs . SetResult ( ) ;
226+ return Task . CompletedTask ;
227+ } ) ;
228+
229+ var app = await builder . BuildAsync ( ) ;
230+ await app . StartAsync ( ) ;
231+ await tcs . Task ;
232+
233+ var urls = adminer . Resource . Annotations . OfType < ResourceUrlAnnotation > ( ) ;
234+ Assert . Single ( urls , u => u . DisplayText == "Adminer Dashboard" ) ;
235+
236+ await app . StopAsync ( ) ;
237+ }
211238}
Original file line number Diff line number Diff line change 11using System . Net . Sockets ;
2+ using Aspire . Components . Common . Tests ;
23using Aspire . Hosting ;
4+ using Aspire . Hosting . Utils ;
35
46namespace CommunityToolkit . Aspire . Hosting . DbGate . Tests ;
57public class AddDbGateTests
@@ -462,4 +464,29 @@ public void WithDbGateShouldShouldAddOneDbGateResourceForMultipleDatabaseTypes()
462464 var containerResource = Assert . Single ( appModel . Resources . OfType < DbGateContainerResource > ( ) ) ;
463465 Assert . Equal ( "mongodb1-dbgate" , containerResource . Name ) ;
464466 }
467+
468+ [ Fact ]
469+ [ RequiresDocker ]
470+ public async Task AddDbGateWithDefaultsAddsUrlAnnotations ( )
471+ {
472+ using var builder = TestDistributedApplicationBuilder . Create ( ) ;
473+
474+ var dbgate = builder . AddDbGate ( "dbgate" ) ;
475+
476+ var tcs = new TaskCompletionSource ( TaskCreationOptions . RunContinuationsAsynchronously ) ;
477+ builder . Eventing . Subscribe < AfterEndpointsAllocatedEvent > ( ( e , ct ) =>
478+ {
479+ tcs . SetResult ( ) ;
480+ return Task . CompletedTask ;
481+ } ) ;
482+
483+ var app = await builder . BuildAsync ( ) ;
484+ await app . StartAsync ( ) ;
485+ await tcs . Task ;
486+
487+ var urls = dbgate . Resource . Annotations . OfType < ResourceUrlAnnotation > ( ) ;
488+ Assert . Single ( urls , u => u . DisplayText == "DbGate Dashboard" ) ;
489+
490+ await app . StopAsync ( ) ;
491+ }
465492}
You can’t perform that action at this time.
0 commit comments