Skip to content
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

test: Add more ACP integration tests #2583

Merged

Conversation

islamaliev
Copy link
Contributor

@islamaliev islamaliev commented May 3, 2024

Resolves #2474 and #2475

Add integration tests for ACP on relation objects and _avg and _count methods.

@islamaliev islamaliev added area/testing Related to any test or testing suite area/acp Related to the acp (access control) system labels May 3, 2024
@islamaliev islamaliev added this to the DefraDB v0.11 milestone May 3, 2024
@islamaliev islamaliev requested a review from a team May 3, 2024 12:01
@islamaliev islamaliev self-assigned this May 3, 2024
Copy link
Contributor

@AndrewSisley AndrewSisley left a comment

Choose a reason for hiding this comment

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

Please break up the functions so that there is one per test. And please make it a little easier for readers to see where the results come from.

Description: "Test acp, query average without identity",

Actions: []any{
getSetupEmployeeCompanyActions(),
Copy link
Contributor

Choose a reason for hiding this comment

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

thought: I cannot see what this test is really testing, unless I bounce between multiple files trying to hold different bits of info in my head and do the maths myself.

suggestion: It would be much easier to read if the stuff under test was all in the same place, and there we comments in useful places (e.g. just above the _avg results field explaining where the number came from).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I cannot see what this test is really testing, unless I bounce between multiple files trying to hold different bits of info in my head and do the maths myself.

This confrontation will never end :)
I agree with your point that the tests needs to be broken up into smaller bits. But then the only thing that will make them different is a single request. And if I inline the setup part it will take 90% of the whole test body.

There is no need to "bounce between multiple files", it's one just to the setup method (potentially only once for all tests) and back.

Phrases like "It would be much easier to read" are highly subjective as it expresses your personal perception.
For me personally it would take much more time to read tests with "the stuff all in the same place", because all this 90% of copy&pasted code needs to be checked as well, right? Otherwise why is it there? It's good when you know the setup code is the same in all tests, but what if you don't?
With the current approach you know it immediately and you see right away what makes these tests differ from one another.

Copy link
Contributor

Choose a reason for hiding this comment

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

This confrontation will never end :)

I'll resist responding here then, as it will just bog the PR down :P Maybe worth a discord thread after the release though.

Please document the tests as-is then, a few code comments explaining what is going on to anyone reading can still greatly improve things here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added some comments when I though it would benefit a reader. Let me know if you think any other part needs more comments.

tests/integration/acp/query/avg_test.go Show resolved Hide resolved
@islamaliev islamaliev requested a review from AndrewSisley May 3, 2024 16:37
Copy link
Member

@nasdf nasdf left a comment

Choose a reason for hiding this comment

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

LGTM. I think there are a few related issues that can be linked.

Copy link
Collaborator

@fredcarle fredcarle 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 adding those tests.

`,
Results: []map[string]any{
{
// 2 public employees, 1 with salary 10k, 1 with salary 20k
Copy link
Contributor

Choose a reason for hiding this comment

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

praise: Thanks for these Islam, I think they are quite useful :)

Copy link
Contributor

@AndrewSisley AndrewSisley 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 Islam - you can probably link #2474 and #2475 to this PR and close them on merge.

Copy link
Member

@shahzadlone shahzadlone left a comment

Choose a reason for hiding this comment

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

Thanks for adding these, you can resolve the related issues.

I do have a slight preference to avoid fixture / setup functions and have it all in the test as Andy suggested. But it's likely a subjective thing and i dont see that as a blocker.

@islamaliev islamaliev force-pushed the tests/acp-relation-tests branch from baedd98 to bd8557f Compare May 3, 2024 19:59
@islamaliev islamaliev merged commit e4c59a9 into sourcenetwork:develop May 3, 2024
27 of 28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/acp Related to the acp (access control) system area/testing Related to any test or testing suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DAC ACP <> Count Operations
5 participants