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

STORAGE-2798 Updated B2StorageClientWebifierImpl methods to improve extensibility #205

Closed
wants to merge 3 commits into from

Conversation

jsha-bbz
Copy link

@jsha-bbz jsha-bbz commented Dec 4, 2024

Updated downloadByName() and downloadById() to use their respective getDownloadByNameUrl() and
getDownloadByIdUrl() methods for improved extensibility

@jsha-bbz jsha-bbz force-pushed the jsha/STORAGE-2798-b2-download-by-name branch from 120b749 to 578493d Compare December 4, 2024 22:23
@@ -1201,7 +1204,7 @@ public void testDownloadById() throws B2Exception {
" X-Bz-Test-Mode: force_cap_exceeded\n"
);

assertEquals(expectedUrl, webifier.getDownloadByIdUrl(ACCOUNT_AUTH, request));
assertEquals(expectedUrl, webifierSpy.getDownloadByIdUrl(ACCOUNT_AUTH, request));
Copy link
Contributor

Choose a reason for hiding this comment

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

why does this need to use the spy'ed object?

Copy link
Author

Choose a reason for hiding this comment

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

It doesn't need to be. Is it a good practice to only use the spy reference when using Mockito calls and the non spy in cases like this? I was thinking it might be less confusing if using the same spy reference throughout the code instead of mixing. Don't mind either way. I'll change it back

webifier.downloadById(ACCOUNT_AUTH, request, noopContentHandler);
final B2StorageClientWebifierImpl webifierSpy = spy(webifier);
webifierSpy.downloadById(ACCOUNT_AUTH, request, noopContentHandler);
verify(webifierSpy).getDownloadByIdUrl(ACCOUNT_AUTH, request);
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm... I think this tests that getDownloadByIdUrl is called but my brain is wondering how useful this verify actually is beyond that. isn't that just an implementation detail? how does verifying it actually tell us more about whether downloadById is working as designed?

Copy link
Author

Choose a reason for hiding this comment

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

I was thinking that the combination of the verify and the assertion in the test would test that downloadById() is working as designed.

The verify checks that the getDownloadByIdUrl() is being called, which is an implementation detail, but an important one as that was the PR change

This verify alone doesn't test that the method is working properly however along with the assertion that the value from the verify call (expectedUrl) is the same as the one being passed to the web client call, we test that we call the right thing and that the right thing is passed.

@jsha-bbz
Copy link
Author

jsha-bbz commented Dec 5, 2024

Closing this PR. As discussed, we don't want clients to create functionality based off of this implementation detail and we will create a better way (pass an http header) to do this

@jsha-bbz jsha-bbz closed this Dec 5, 2024
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.

2 participants