-
Notifications
You must be signed in to change notification settings - Fork 463
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
Adding public API test coverage for Aspire.Hosting.Valkey #5054
base: main
Are you sure you want to change the base?
Changes from all commits
dbf8b30
cad5e67
6d8de23
c50bd55
863ce14
47242db
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
// 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; | ||
using Xunit; | ||
|
||
namespace Aspire.Hosting.Valkey.Tests; | ||
|
||
public class ValkeyPublicApiTests | ||
{ | ||
#region ValkeyBuilderExtensions | ||
|
||
[Fact] | ||
public void AddValkeyContainerShouldThrowWhenBuilderIsNull() | ||
{ | ||
IDistributedApplicationBuilder builder = null!; | ||
const string name = "Valkey"; | ||
|
||
var action = () => builder.AddValkey(name); | ||
|
||
var exception = Assert.Throws<ArgumentNullException>(action); | ||
Assert.Equal(nameof(builder), exception.ParamName); | ||
} | ||
|
||
[Fact] | ||
public void AddValkeyContainerShouldThrowWhenNameIsNull() | ||
{ | ||
IDistributedApplicationBuilder builder = new DistributedApplicationBuilder([]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use TestDistributedApplicationBuilder.Create(); |
||
string name = null!; | ||
|
||
var action = () => builder.AddValkey(name); | ||
|
||
var exception = Assert.Throws<ArgumentNullException>(action); | ||
Assert.Equal(nameof(name), exception.ParamName); | ||
} | ||
|
||
[Fact] | ||
public void WithDataVolumeShouldThrowWhenBuilderIsNull() | ||
{ | ||
IResourceBuilder<ValkeyResource> builder = null!; | ||
|
||
var action = () => builder.WithDataVolume(); | ||
|
||
var exception = Assert.Throws<ArgumentNullException>(action); | ||
Assert.Equal(nameof(builder), exception.ParamName); | ||
} | ||
|
||
[Fact] | ||
public void WithDataBindMountShouldThrowWhenBuilderIsNull() | ||
{ | ||
IResourceBuilder<ValkeyResource> builder = null!; | ||
const string source = "Valkey"; | ||
|
||
var action = () => builder.WithDataBindMount(source); | ||
|
||
var exception = Assert.Throws<ArgumentNullException>(action); | ||
Assert.Equal(nameof(builder), exception.ParamName); | ||
} | ||
|
||
[Fact] | ||
public void WithDataBindMountShouldThrowWhenSourceIsNull() | ||
{ | ||
var distributedApplicationBuilder = new DistributedApplicationBuilder([]); | ||
const string name = "Valkey"; | ||
var resource = new ValkeyResource(name); | ||
var builder = distributedApplicationBuilder.AddResource(resource); | ||
string source = null!; | ||
|
||
var action = () => builder.WithDataBindMount(source); | ||
|
||
var exception = Assert.Throws<ArgumentNullException>(action); | ||
Assert.Equal(nameof(source), exception.ParamName); | ||
} | ||
|
||
[Fact] | ||
public void WithPersistenceShouldThrowWhenBuilderIsNull() | ||
{ | ||
IResourceBuilder<ValkeyResource> builder = null!; | ||
|
||
var action = () => builder.WithPersistence(); | ||
|
||
var exception = Assert.Throws<ArgumentNullException>(action); | ||
Assert.Equal(nameof(builder), exception.ParamName); | ||
} | ||
|
||
#endregion | ||
|
||
#region ValkeyResource | ||
|
||
[Fact] | ||
public void CtorValkeyResourceShouldThrowWhenNameIsNull() | ||
{ | ||
string name = null!; | ||
|
||
var action = () => new ValkeyResource(name); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a static check in the class |
||
|
||
var exception = Assert.Throws<ArgumentNullException>(action); | ||
Assert.Equal(nameof(name), exception.ParamName); | ||
} | ||
|
||
#endregion | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove Addrees pls.