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: standardize test function names across codebase #504

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MukulKolpe
Copy link
Contributor

This PR standardizes test function names across the codebase following a consistent pattern:

  • function_name_description for successful tests.
  • function_name_revert_when_condition for tests expecting a revert.

Resolves #491

PR Checklist

  • Tests
  • Documentation
  • Changelog

Copy link

netlify bot commented Jan 22, 2025

Deploy Preview for contracts-stylus canceled.

Name Link
🔨 Latest commit 1f1e0b5
🔍 Latest deploy log https://app.netlify.com/sites/contracts-stylus/deploys/67904c152737120008580677

Copy link
Collaborator

@bidzyyys bidzyyys left a comment

Choose a reason for hiding this comment

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

@@ -412,26 +412,26 @@ mod tests {
}

#[motsu::test]
fn default_role_is_default_admin(contract: AccessControl) {
fn default_admin_role_success(contract: AccessControl) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
fn default_admin_role_success(contract: AccessControl) {
fn get_role_admin_returns_default_admin_for_regular_role(
contract: AccessControl,
) {

Don't forget the requirements:

function_name_description for successful tests.

function_name is the name of the function that is being tested, and this should apply to getters as well.

Double check that all the other test names follow this convention.

let role_admin = contract.get_role_admin(ROLE.into());
assert_eq!(role_admin, AccessControl::DEFAULT_ADMIN_ROLE);
}

#[motsu::test]
fn default_admin_roles_admin_is_itself(contract: AccessControl) {
fn default_admin_role_admin_success(contract: AccessControl) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
fn default_admin_role_admin_success(contract: AccessControl) {
fn get_role_admin_returns_default_admin_for_default_admin_role(
contract: AccessControl,
) {

@@ -522,7 +522,7 @@ mod tests {
}

#[motsu::test]
fn the_new_admin_can_grant_roles(contract: AccessControl) {
fn role_admin_change_success_with_new_grant(contract: AccessControl) {
Copy link
Collaborator

@0xNeshi 0xNeshi Jan 22, 2025

Choose a reason for hiding this comment

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

Suggested change
fn role_admin_change_success_with_new_grant(contract: AccessControl) {
fn grant_role_succeeds_when_called_by_new_admin(contract: AccessControl) {
  • grant_role is actually being tested here
  • related to the comment above, make sure that all test case names follow the expected convention

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.

[Feature]: Test Name Standardization
3 participants