Skip to content

Conversation

@firerain-fd
Copy link
Contributor

class Selectors:
Add Property ServiceName

class ServiceSelector:
Add operator ==
Add operator !=
Add Tests

class Agent:
Add method Checks with filter
Add Tests

+ Property ServiceName

class ServiceSelector:
+ operator ==
+ operator !=
+ Tests

class Agent:
+ method Checks with filter
+ Tests
Copy link
Contributor

@marcin-krystianc marcin-krystianc left a comment

Choose a reason for hiding this comment

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

Hi @firerain-fd, thanks for being an active contributor.

I've reviewed your changes. I see how the "ServiceName" selector is being used, but I don't see how "Service" selector is being used (or can be even used). Please provide a use case (a test case) or remove that change.


public override string Encode() => Self;

public static Filter operator ==(ServiceSelector selector, string value) => Filters.Eq(selector, value);
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think a "service" is a valid selector that can be used for anything. Also, this is not being used in an actual test (apart from encoding tests). I think that it should be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, I see. It would be great though if you implement at least one test case which uses this APIs.

Task<WriteResult> CheckDeregister(string checkID, CancellationToken ct = default(CancellationToken));
Task<WriteResult> CheckRegister(AgentCheckRegistration check, CancellationToken ct = default(CancellationToken));
Task<QueryResult<Dictionary<string, AgentCheck>>> Checks(CancellationToken ct = default(CancellationToken));
Task<QueryResult<Dictionary<string, AgentCheck>>> Checks(Filter filter, CancellationToken ct = default(CancellationToken));
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

}

[Fact]
public async Task Agent_FilterChecks()
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Fixed filtering test assertion by service identifier (duplicated string).
Added filtering test assertion by service name.
Assert.Equal(svcID2, (await _client.Agent.Services(idSelector == svcID2)).Response.Keys.Single());
Assert.Equal(svcID1, (await _client.Agent.Services(metaSelector[uniqueMeta] == "bar1")).Response.Keys.Single());
Assert.Equal(svcID2, (await _client.Agent.Services(metaSelector[uniqueMeta] == "bar2")).Response.Keys.Single());
Assert.Equal(svcID1, (await _client.Agent.Services(Selectors.Service == svcID1)).Response.Keys.Single());
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

@marcin-krystianc marcin-krystianc left a comment

Choose a reason for hiding this comment

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

Nice, thank you for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants