Skip to content

Commit 414747e

Browse files
Copilotaaronpowell
andcommitted
Add tests for installer resources and update Dapr tests
Co-authored-by: aaronpowell <434140+aaronpowell@users.noreply.github.com>
1 parent 0d3ab6c commit 414747e

File tree

3 files changed

+41
-7
lines changed

3 files changed

+41
-7
lines changed

tests/CommunityToolkit.Aspire.Hosting.Bun.Tests/AddBunAppTests.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Aspire.Hosting;
2+
using Aspire.Hosting.ApplicationModel;
23

34
namespace CommunityToolkit.Aspire.Hosting.Bun.Tests;
45

@@ -140,4 +141,22 @@ public void AddBunEmptyEntryPointThrows()
140141

141142
Assert.Throws<ArgumentException>(() => builder.AddBunApp("bun", entryPoint: ""));
142143
}
144+
145+
[Fact]
146+
public void BunAppWithPackageInstallationCreatesInstallerResource()
147+
{
148+
var builder = DistributedApplication.CreateBuilder();
149+
150+
builder.AddBunApp("bun").WithBunPackageInstallation();
151+
152+
using var app = builder.Build();
153+
154+
var appModel = app.Services.GetRequiredService<DistributedApplicationModel>();
155+
156+
var bunResource = Assert.Single(appModel.Resources.OfType<BunAppResource>());
157+
var installerResource = Assert.Single(appModel.Resources.OfType<BunInstallerResource>());
158+
159+
Assert.Equal("bun-bun-install", installerResource.Name);
160+
Assert.Equal("bun", installerResource.Command);
161+
}
143162
}

tests/CommunityToolkit.Aspire.Hosting.Dapr.Tests/DaprTests.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
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.Runtime.CompilerServices;
54
using Aspire.Hosting;
65
using Aspire.Hosting.Utils;
76

@@ -30,7 +29,7 @@ public async Task WithDaprSideCarAddsAnnotationAndSidecarResource()
3029

3130
using var app = builder.Build();
3231

33-
await ExecuteBeforeStartHooksAsync(app, default);
32+
await app.StartAsync();
3433

3534
var model = app.Services.GetRequiredService<DistributedApplicationModel>();
3635

@@ -129,7 +128,7 @@ public async Task WithDaprSideCarAddsAnnotationBasedOnTheSidecarAppOptions(strin
129128
});
130129
}
131130
using var app = builder.Build();
132-
await ExecuteBeforeStartHooksAsync(app, default);
131+
await app.StartAsync();
133132

134133
var model = app.Services.GetRequiredService<DistributedApplicationModel>();
135134

@@ -165,7 +164,4 @@ public async Task WithDaprSideCarAddsAnnotationBasedOnTheSidecarAppOptions(strin
165164
Assert.Contains($"--app-protocol {expectedSchema}", commandline);
166165
Assert.NotNull(container.Annotations.OfType<DaprSidecarAnnotation>());
167166
}
168-
169-
[UnsafeAccessor(UnsafeAccessorKind.Method, Name = "ExecuteBeforeStartHooksAsync")]
170-
private static extern Task ExecuteBeforeStartHooksAsync(DistributedApplication app, CancellationToken cancellationToken);
171167
}

tests/CommunityToolkit.Aspire.Hosting.Deno.Tests/ResourceCreationTests.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Aspire.Hosting;
2+
using Aspire.Hosting.ApplicationModel;
23

34
namespace CommunityToolkit.Aspire.Hosting.Deno.Tests;
45

@@ -40,4 +41,22 @@ public void DenoAppUsesDenoCommand()
4041

4142
Assert.Equal("deno", resource.Command);
4243
}
43-
}
44+
45+
[Fact]
46+
public void DenoAppWithPackageInstallationCreatesInstallerResource()
47+
{
48+
var builder = DistributedApplication.CreateBuilder();
49+
50+
builder.AddDenoApp("deno", Environment.CurrentDirectory).WithDenoPackageInstallation();
51+
52+
using var app = builder.Build();
53+
54+
var appModel = app.Services.GetRequiredService<DistributedApplicationModel>();
55+
56+
var denoResource = Assert.Single(appModel.Resources.OfType<DenoAppResource>());
57+
var installerResource = Assert.Single(appModel.Resources.OfType<DenoInstallerResource>());
58+
59+
Assert.Equal("deno-deno-install", installerResource.Name);
60+
Assert.Equal("deno", installerResource.Command);
61+
}
62+
}

0 commit comments

Comments
 (0)