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

Make socket listener tests more readable. #1027

Merged
merged 9 commits into from
Feb 25, 2024

Conversation

nihohit
Copy link
Contributor

@nihohit nihohit commented Feb 22, 2024

Issue #, if available:

Description of changes:
The tests are made simpler by

  1. moving repeated logic to side functions, thus reducing the focusing the tests on their intention, rather than implementation details.
  2. replacing booleans with enums, in order to make the test configuration more readable. setup_basics(true, false, true) is hard to decipher, and requires reading the function's signature in order to understand.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@nihohit nihohit requested a review from a team as a code owner February 22, 2024 18:44
bool,
),
#[values(true, false)] use_cluster: bool,
#[values((false, Tls::NoTls), (true, Tls::NoTls), (false,Tls::UseTls))]
Copy link
Collaborator

Choose a reason for hiding this comment

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

minor: missing space (false,Tls::UseTls)) -> (false, Tls::UseTls))

bool,
),
#[values(true, false)] use_cluster: bool,
#[values((false, Tls::NoTls), (true, Tls::NoTls), (false,Tls::UseTls))]
Copy link
Collaborator

Choose a reason for hiding this comment

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

(fix allover)

}
}

enum Sharing {
Copy link
Collaborator

Choose a reason for hiding this comment

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

'Sharing' still doesn't give enough info for readers - maybe TestServerType, or SharingServer?

@shachlanAmazon shachlanAmazon merged commit d0b0b03 into valkey-io:main Feb 25, 2024
3 checks passed
@nihohit nihohit deleted the simplify-tests branch February 25, 2024 11:40
cyip10 pushed a commit to Bit-Quill/valkey-glide that referenced this pull request Jun 24, 2024
* Move socket reading into response assert.

This removes reading from socket before asserting on the read value from multiple tests.

* Add helper function to assert on values.

* Remove unused cursor argument.

* Move repeating read logic to function.

* Increase setup legibility.

2-3 booleans in a row are hard to read without confusion. Using enums instead.

* Move repeated writing logic to write helpers.

* Add pointer to value helper function.

* Add another writer helper method.

* fix comments
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.

3 participants