-
Notifications
You must be signed in to change notification settings - Fork 733
Adding public API test coverage for Aspire.Hosting.Qdrant #5099
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
Merged
eerhardt
merged 14 commits into
dotnet:main
from
Zombach:zombach/validate-arguments-of-public-methods#aspire-hosting-qdrant
Aug 1, 2024
Merged
Changes from 13 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
280a590
CA1062#Aspire.Hosting.Qdrant
Zombach 7d06e54
Merge branch 'dotnet:main' into zombach/validate-arguments-of-public-…
Zombach 7e30ab6
Merge branch 'dotnet:main' into zombach/validate-arguments-of-public-…
Zombach eaab4bf
Completing fix CA1062
Zombach 7d0899b
Merge branch 'dotnet:main' into zombach/validate-arguments-of-public-…
Zombach b796c92
Fix names
Zombach 4fb6d45
Fix name Test 'name' => 'source'
Zombach 33d9e17
Merge branch 'dotnet:main' into zombach/validate-arguments-of-public-…
Zombach 91812fd
Remove Assert.Multiple by feedback
Zombach 34bb900
Fix by Feedback
Zombach 9e512e0
Merge branch 'dotnet:main' into zombach/validate-arguments-of-public-…
Zombach 093d3f5
Merge branch 'dotnet:main' into zombach/validate-arguments-of-public-…
Zombach 09ab34a
Merge branch 'dotnet:main' into zombach/validate-arguments-of-public-…
Zombach dfb386e
Address PR feedback
eerhardt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
131 changes: 131 additions & 0 deletions
131
tests/Aspire.Hosting.Qdrant.Tests/QdrantPublicApiTests.cs
This file contains hidden or 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,131 @@ | ||
| // 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 Aspire.Hosting.Utils; | ||
| using Xunit; | ||
|
|
||
| namespace Aspire.Hosting.Qdrant.Tests; | ||
|
|
||
| public class QdrantPublicApiTests | ||
| { | ||
| #region QdrantBuilderExtensions | ||
|
|
||
| [Fact] | ||
| public void AddQdrantContainerShouldThrowWhenBuilderIsNull() | ||
| { | ||
| IDistributedApplicationBuilder builder = null!; | ||
| const string name = "Qdrant"; | ||
|
|
||
| var action = () => builder.AddQdrant(name); | ||
|
|
||
| var exception = Assert.Throws<ArgumentNullException>(action); | ||
| Assert.Equal(nameof(builder), exception.ParamName); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void AddQdrantContainerShouldThrowWhenNameIsNull() | ||
| { | ||
| var builder = DistributedApplication.CreateBuilder([]); | ||
| string name = null!; | ||
|
|
||
| var action = () => builder.AddQdrant(name); | ||
|
|
||
| var exception = Assert.Throws<ArgumentNullException>(action); | ||
| Assert.Equal(nameof(name), exception.ParamName); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void WithDataVolumeShouldThrowWhenBuilderIsNull() | ||
| { | ||
| IResourceBuilder<QdrantServerResource> builder = null!; | ||
|
|
||
| var action = () => builder.WithDataVolume(); | ||
|
|
||
| var exception = Assert.Throws<ArgumentNullException>(action); | ||
| Assert.Equal(nameof(builder), exception.ParamName); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void WithDataBindMountShouldThrowWhenBuilderIsNull() | ||
| { | ||
| IResourceBuilder<QdrantServerResource> builder = null!; | ||
| const string source = "/qdrant/storage"; | ||
|
|
||
| var action = () => builder.WithDataBindMount(source); | ||
|
|
||
| var exception = Assert.Throws<ArgumentNullException>(action); | ||
| Assert.Equal(nameof(builder), exception.ParamName); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void WithDataBindMountShouldThrowWhenSourceIsNull() | ||
| { | ||
| var builderResource = TestDistributedApplicationBuilder.Create(); | ||
| var qdrant = builderResource.AddQdrant("Qdrant"); | ||
| string source = null!; | ||
|
|
||
| var action = () => qdrant.WithDataBindMount(source); | ||
|
|
||
| var exception = Assert.Throws<ArgumentNullException>(action); | ||
| Assert.Equal(nameof(source), exception.ParamName); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void WithReferenceShouldThrowWhenBuilderIsNull() | ||
| { | ||
| IResourceBuilder<IResourceWithEnvironment> builder = null!; | ||
| var builderResource = TestDistributedApplicationBuilder.Create(); | ||
| var qdrantResource = builderResource.AddQdrant("Qdrant"); | ||
|
|
||
| var action = () => builder.WithReference(qdrantResource); | ||
|
|
||
| var exception = Assert.Throws<ArgumentNullException>(action); | ||
| Assert.Equal(nameof(builder), exception.ParamName); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void WithReferenceShouldThrowWhenQdrantResourceIsNull() | ||
| { | ||
| var builder = TestDistributedApplicationBuilder.Create(); | ||
| var qdrant = builder.AddQdrant("Qdrant"); | ||
| IResourceBuilder<QdrantServerResource> qdrantResource = null!; | ||
|
|
||
| var action = () => qdrant.WithReference(qdrantResource); | ||
|
|
||
| var exception = Assert.Throws<ArgumentNullException>(action); | ||
| Assert.Equal(nameof(qdrantResource), exception.ParamName); | ||
| } | ||
|
|
||
| #endregion | ||
|
|
||
| #region QdrantServerResource | ||
|
|
||
| [Fact] | ||
| public void CtorQdrantServerResourceShouldThrowWhenNameIsNull() | ||
| { | ||
| var distributedApplicationBuilder = DistributedApplication.CreateBuilder([]); | ||
| string name = null!; | ||
| const string key = nameof(key); | ||
| var apiKey = ParameterResourceBuilderExtensions.CreateDefaultPasswordParameter(distributedApplicationBuilder, key, special: false); | ||
|
|
||
| var action = () => new QdrantServerResource(name, apiKey); | ||
|
|
||
| var exception = Assert.Throws<ArgumentNullException>(action); | ||
| Assert.Equal(nameof(name), exception.ParamName); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void CtorQdrantServerResourceShouldThrowWhenApiKeyIsNull() | ||
| { | ||
| const string name = "Qdrant"; | ||
| ParameterResource apiKey = null!; | ||
|
|
||
| var action = () => new QdrantServerResource(name, apiKey); | ||
|
|
||
| var exception = Assert.Throws<ArgumentNullException>(action); | ||
| Assert.Equal(nameof(apiKey), exception.ParamName); | ||
| } | ||
|
|
||
| #endregion | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.