From 31ad012880278d46cbab005128a54ea16a5a9270 Mon Sep 17 00:00:00 2001 From: Reuben Bond Date: Wed, 10 Apr 2024 15:02:55 -0700 Subject: [PATCH] Fix VerifyDockerWithBindMountWorksWithAbsolutePaths test --- .../Aspire.Hosting.Tests/DistributedApplicationTests.cs | 9 +++++---- tests/Aspire.Hosting.Tests/Redis/AddRedisTests.cs | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/Aspire.Hosting.Tests/DistributedApplicationTests.cs b/tests/Aspire.Hosting.Tests/DistributedApplicationTests.cs index ce29f387ed..a6cb661b92 100644 --- a/tests/Aspire.Hosting.Tests/DistributedApplicationTests.cs +++ b/tests/Aspire.Hosting.Tests/DistributedApplicationTests.cs @@ -409,8 +409,9 @@ public async Task VerifyDockerWithBindMountWorksWithAbsolutePaths() using var testProgram = CreateTestProgram(); testProgram.AppBuilder.Services.AddLogging(b => b.AddXunit(_testOutputHelper)); + var sourcePath = Path.GetFullPath("/etc/path-here"); testProgram.AppBuilder.AddContainer("redis-cli", "redis") - .WithBindMount("/etc/path-here", $"path-here"); + .WithBindMount(sourcePath, "path-here"); await using var app = testProgram.Build(); @@ -428,7 +429,7 @@ public async Task VerifyDockerWithBindMountWorksWithAbsolutePaths() Assert.NotNull(redisContainer.Spec.VolumeMounts); Assert.NotEmpty(redisContainer.Spec.VolumeMounts); - Assert.Equal("/etc/path-here", redisContainer.Spec.VolumeMounts[0].Source); + Assert.Equal(sourcePath, redisContainer.Spec.VolumeMounts[0].Source); await app.StopAsync(); } @@ -440,7 +441,7 @@ public async Task VerifyDockerWithBindMountWorksWithRelativePaths() testProgram.AppBuilder.Services.AddLogging(b => b.AddXunit(_testOutputHelper)); testProgram.AppBuilder.AddContainer("redis-cli", "redis") - .WithBindMount("etc/path-here", $"path-here"); + .WithBindMount("etc/path-here", "path-here"); await using var app = testProgram.Build(); @@ -471,7 +472,7 @@ public async Task VerifyDockerWithVolumeWorksWithName() testProgram.AppBuilder.Services.AddLogging(b => b.AddXunit(_testOutputHelper)); testProgram.AppBuilder.AddContainer("redis-cli", "redis") - .WithVolume("test-volume-name", $"/path-here"); + .WithVolume("test-volume-name", "/path-here"); await using var app = testProgram.Build(); diff --git a/tests/Aspire.Hosting.Tests/Redis/AddRedisTests.cs b/tests/Aspire.Hosting.Tests/Redis/AddRedisTests.cs index 505934850d..94c788e227 100644 --- a/tests/Aspire.Hosting.Tests/Redis/AddRedisTests.cs +++ b/tests/Aspire.Hosting.Tests/Redis/AddRedisTests.cs @@ -213,7 +213,7 @@ public void WithDataBindMountAddsMountAnnotation(bool? isReadOnly) var volumeAnnotation = redis.Resource.Annotations.OfType().Single(); - Assert.Equal(Path.GetFullPath("mydata"), volumeAnnotation.Source); + Assert.Equal(Path.Combine(builder.AppHostDirectory, "mydata"), volumeAnnotation.Source); Assert.Equal("/data", volumeAnnotation.Target); Assert.Equal(ContainerMountType.BindMount, volumeAnnotation.Type); Assert.Equal(isReadOnly ?? false, volumeAnnotation.IsReadOnly);