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

Add new file tests to OdkWebserverServiceTest #270

Open
wants to merge 6 commits into
base: development
Choose a base branch
from

Conversation

permission-error
Copy link

@permission-error permission-error commented Jan 12, 2024

Pull Request Description:

This pull request introduces several changes to the OdkWebserverServiceTest class in the org.opendatakit.webkitserver.service package. Here's a summary of the changes:

1. Added Permission Rules:

  • Added GrantPermissionRule for WRITE_EXTERNAL_STORAGE and READ_EXTERNAL_STORAGE permissions to the test class.

2. Updated Test Methods:

  • Updated test methods to create and serve various types of files and handle different scenarios, including serving HTML files, empty files, large files, files with special characters in their names, files with spaces in their names, files with Unicode characters in their content, files with invalid extensions, files with uppercase extensions, binary files, files with multiple dots in their names, files with no extension, and files with different extensions.

  • Added assertions to verify the responses from the web server for each test scenario.

3. Refactored Code:

  • Refactored some methods for improved readability and maintainability.
  • Cleaned up imports and removed unused imports.

4. Miscellaneous Changes:

  • Updated comments for better clarity and documentation.
  • Removed unnecessary exception printing and added fail messages for better error reporting in tests.

Tags @wbrunette @Lamouresparus

@Test
public void testServingLargeFile() {
// Setup
File directoryLocation = createTestDirectory();
Copy link
Member

Choose a reason for hiding this comment

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

Replace the File with URI

@wbrunette
Copy link
Member

Instead of using "File" class use the URI style

@wbrunette
Copy link
Member

@permission-error let's chat about this PR during your meeting

@wbrunette
Copy link
Member

wbrunette commented Feb 4, 2024

While your refactor of code improves the code, you still need to switch to the URI format in your private helper functions because when we remove the use legacy flag we are likely to see issues. Once file is created using URI interface it is fine to covert to file in your code.

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