-
Notifications
You must be signed in to change notification settings - Fork 475
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove RedisContainerResource and containerize RedisResource. (#2073)
* Remove RedisContainerResource and containerize RedisResource. * Fix up tests. * Test doesn't need PublishAsContainer()..
- Loading branch information
1 parent
6d36161
commit 1b94656
Showing
11 changed files
with
124 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 4 additions & 3 deletions
7
src/Aspire.Hosting/Redis/IRedisResource.cs → ...del/ResourceAnnotationMutationBehavior.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using Aspire.Hosting.ApplicationModel; | ||
namespace Aspire.Hosting.ApplicationModel; | ||
|
||
namespace Aspire.Hosting.Redis; | ||
public interface IRedisResource : IResourceWithConnectionString | ||
public enum ResourceAnnotationMutationBehavior | ||
{ | ||
Append, | ||
Replace | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using Xunit; | ||
|
||
namespace Aspire.Hosting.Tests.Utils; | ||
|
||
public class WithAnnotationTests | ||
{ | ||
[Fact] | ||
public void WithAnnotationWithTypeParameterAndNoExplicitBehaviorAppends() | ||
{ | ||
var builder = DistributedApplication.CreateBuilder(); | ||
var redis = builder.AddRedis("redis") | ||
.WithAnnotation<DummyAnnotation>() | ||
.WithAnnotation<DummyAnnotation>(); | ||
|
||
var dummyAnnotations = redis.Resource.Annotations.OfType<DummyAnnotation>(); | ||
|
||
Assert.Equal(2, dummyAnnotations.Count()); | ||
Assert.NotEqual(dummyAnnotations.First(), dummyAnnotations.Last()); | ||
} | ||
|
||
[Fact] | ||
public void WithAnnotationWithTypeParameterAndArgumentAndNoExplicitBehaviorAppends() | ||
{ | ||
var builder = DistributedApplication.CreateBuilder(); | ||
var redis = builder.AddRedis("redis") | ||
.WithAnnotation<DummyAnnotation>(new DummyAnnotation()) | ||
.WithAnnotation<DummyAnnotation>(new DummyAnnotation()); | ||
|
||
var dummyAnnotations = redis.Resource.Annotations.OfType<DummyAnnotation>(); | ||
|
||
Assert.Equal(2, dummyAnnotations.Count()); | ||
Assert.NotEqual(dummyAnnotations.First(), dummyAnnotations.Last()); | ||
} | ||
|
||
[Fact] | ||
public void WithAnnotationWithTypeParameterAndArgumentAndAddReplaceBehaviorReplaces() | ||
{ | ||
var builder = DistributedApplication.CreateBuilder(); | ||
var redis = builder.AddRedis("redis").WithAnnotation<DummyAnnotation>(); | ||
|
||
var firstAnnotation = redis.Resource.Annotations.OfType<DummyAnnotation>().Single(); | ||
|
||
redis.WithAnnotation<DummyAnnotation>(ResourceAnnotationMutationBehavior.Replace); | ||
|
||
var secondAnnotation = redis.Resource.Annotations.OfType<DummyAnnotation>().Single(); | ||
|
||
Assert.NotEqual(firstAnnotation, secondAnnotation); | ||
} | ||
} | ||
|
||
public class DummyAnnotation : IResourceAnnotation | ||
{ | ||
} |