Skip to content

Conversation

@Zombach
Copy link
Contributor

@Zombach Zombach commented Jul 29, 2024

Initial issues #2649
Issues Check List: Validate arguments of public methods

Microsoft Reviewers: Open in CodeFlow

@ghost ghost added the area-codeflow for labeling automated codeflow. intentionally a different color! label Jul 29, 2024
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Jul 29, 2024
}

[Fact]
public void WithDataBindMountShouldThrowsWhenNameIsNull()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is testing the source (source directory) parameter, and not name.

Comment on lines 75 to 82
var distributedApplicationBuilder = DistributedApplication.CreateBuilder([]);
const string name = "Qdrant";
var apiKeyParameter = ParameterResourceBuilderExtensions.CreateDefaultPasswordParameter(distributedApplicationBuilder, $"{name}-Key", special: false);
var resource = new QdrantServerResource(name, apiKeyParameter);
var builder = distributedApplicationBuilder.AddResource(resource);
string source = null!;

var action = () => builder.WithDataBindMount(source);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need all this or would something like this be enough?:

        IResourceBuilder<QdrantServerResource> builder = null!;
        string source = null!;
        var action = () => builder.WithDataBindMount(source);

@eerhardt @sebastienros thoughts?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, it doesn't need to be that complicated. Even the Multiple usage in all these tests, since the second assertion depends on the first, we don't care about the second result if the first one failed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiple

Indeed, I will remove Multiple.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need all this or would something like this be enough?:

        IResourceBuilder<QdrantServerResource> builder = null!;
        string source = null!;
        var action = () => builder.WithDataBindMount(source);

@eerhardt @sebastienros thoughts?

But in this case. We will not handle the error when builder 'is not null' and source 'is null'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full test

var builder = TestDistributedApplicationBuilder.Create();
var qdrant = builder.AddQdrant("qdrant");
string source = null!;

var action = () => qdrant.WithDataBindMount(source);
var exception = Assert.Throws<ArgumentNullException>(action);
Assert.Equal(nameof(source), exception.ParamName);

@radical radical added area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication testing ☑️ and removed area-codeflow for labeling automated codeflow. intentionally a different color! testing ☑️ labels Jul 30, 2024
@Zombach Zombach changed the title CA1062#Aspire.Hosting.Qdrant Adding public API test coverage for Aspire.Hosting.Qdrant Jul 31, 2024
Copy link
Member

@eerhardt eerhardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for the contribution!

@eerhardt eerhardt enabled auto-merge (squash) August 1, 2024 15:39
@eerhardt eerhardt merged commit 72598d7 into dotnet:main Aug 1, 2024
@Zombach Zombach deleted the zombach/validate-arguments-of-public-methods#aspire-hosting-qdrant branch August 2, 2024 16:21
@github-actions github-actions bot locked and limited conversation to collaborators Sep 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants