Skip to content
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