Skip to content

Improve tests regarding permissions #217

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

Merged
merged 1 commit into from
Mar 8, 2025

Conversation

Sakib25800
Copy link
Contributor

Fixes #212

@Sakib25800
Copy link
Contributor Author

Sakib25800 commented Mar 7, 2025

For PR #210, we could do something simple like:

fn create_world_with_delegate_config() -> World {
        let world = World::default();
        world.default_repo().lock().set_config(
            r#"
[labels]
approve = ["+approved"]
"#,
        );
        // Remove all permissions from PR author. 
        world
            .default_repo()
            .lock()
            .permissions
            .users
            .remove(&User::default());

        world
    }

This achieves the state we want.

PR #210 will probably need a few changes test wise, either via another PR or directly - whichever is suggested.

@Sakib25800 Sakib25800 changed the title Refactor: Add prebuilt test users Improve tests regarding permissions Mar 7, 2025
Copy link
Member

@Kobzol Kobzol left a comment

Choose a reason for hiding this comment

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

This is a nice clean-up, thanks. I think that the API could be still a bit nicer and more bulletproof, but that's for a larger refactoring. Also we should somehow check that the unprivileged user won't ever have any privileges in tests, but that might be tricky to verify, and it shouldn't happen by accident, so it should be fine.

Left one comment, otherwise LGTM.

Copy link
Member

@Kobzol Kobzol left a comment

Choose a reason for hiding this comment

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

Thanks!

@Kobzol
Copy link
Member

Kobzol commented Mar 7, 2025

Oh, this will need a rebase :)

@Sakib25800 Sakib25800 force-pushed the refactor/prebuilt-test-users branch from bfd0140 to d4f7a66 Compare March 7, 2025 16:41
@Kobzol Kobzol added this pull request to the merge queue Mar 8, 2025
Merged via the queue into rust-lang:main with commit a02b8b3 Mar 8, 2025
2 checks passed
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.

Improve tests regarding permissions
2 participants