Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test to cover WithReference usage with Python projects. #5118

Merged
merged 2 commits into from
Jul 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions tests/Aspire.Hosting.Python.Tests/AddPythonProjectTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,28 @@ public async Task PythonResourceFinishesSuccessfully()
Directory.Delete(projectDirectory, true);
}

[Fact]
[RequiresTools(["python"])]
public async Task PythonResourceSupportsWithReference()
{
var (projectDirectory, _, scriptName) = CreateTempPythonProject(outputHelper);

using var builder = CreateTestDistributedApplicationBuilder();

var externalResource = builder.AddConnectionString("connectionString");
builder.Configuration["ConnectionStrings:connectionString"] = "test";

var pyproj = builder.AddPythonProject("pyproj", projectDirectory, scriptName)
.WithReference(externalResource);

var environmentVariables = await pyproj.Resource.GetEnvironmentVariableValuesAsync(DistributedApplicationOperation.Run);

Assert.Equal("test", environmentVariables["ConnectionStrings__connectionString"]);

// If we don't throw, clean up the directories.
Directory.Delete(projectDirectory, true);
}

[Fact]
[RequiresTools(["python"])]
public async Task AddPythonProject_SetsResourcePropertiesCorrectly()
Expand Down