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

feat: RepositoryProvider.revision now public property #5500

Merged
merged 5 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ abstract class RepositoryProvider {
/**
* The name of the commit/branch/tag
*/
protected String revision
String revision
pditommaso marked this conversation as resolved.
Show resolved Hide resolved

RepositoryProvider setCredentials(String userName, String password) {
config.user = userName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,15 @@ class RepositoryProviderTest extends Specification {
and:
1 * conn.setRequestProperty('Authorization', "Basic ${'foo:bar'.bytes.encodeBase64()}")
}

def 'should have public revision property' () {
given:
def provider = Spy(RepositoryProvider)
when:
provider.revision = 'branch_or_tag'
then:
provider.revision == 'branch_or_tag'
provider.hasProperty('revision') ? true : false
}
Copy link
Member

Choose a reason for hiding this comment

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

Do we need a unit test for this? I don't think the test will actually test anything because Spock can access protected members on a spy anyway

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The property getter (i.e. provider.revision == 'branch_or_tag'), definitely raises a MissingMethodException exception if the field is protected. Although tbh I wasn't expecting that as the test is in the same package, so should have access. The hasProperty test was my attempt to assert that is is actually property and hence public.

This is however moot given Paolo's comments below which I will address. And this test will go away.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Another option here would be to have test in another package to assert the public API. I don't currently see this pattern in the repo though, so will take you guidance on whether this is required of not.


}