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

Cleanup download tests #1457

Merged
merged 2 commits into from
Aug 11, 2022
Merged

Cleanup download tests #1457

merged 2 commits into from
Aug 11, 2022

Conversation

nagmat84
Copy link
Collaborator

This is a follow-up to #1453. I already wanted to do that yesterday, but wanted to keep the re-factoring out of #1453.

  1. It moves all download tests from the general PhotosOperationsTest to the new and specialized test class PhotosDownloadTest in order to keep them together.
  2. We test different ZIP archives in several tests. I moved the boiler-plate code to handle ZIP archives and make assertions about them into a new class AssertableZIPArchive

@codecov
Copy link

codecov bot commented Aug 10, 2022

Codecov Report

Merging #1457 (c0e79ac) into master (420beb4) will decrease coverage by 0.81%.
The diff coverage is n/a.

@ildyria
Copy link
Member

ildyria commented Aug 11, 2022

I am wondering if we should add a helper function which given a path foo/../bar/image.ext returns image.ext.
This would avoid having magic constants in our tests.

@nagmat84
Copy link
Collaborator Author

No need to add helper function for that. fileinfo (I believe, or pathinfo?) does the job.

But I am more curious where you want to use it?

@ildyria
Copy link
Member

ildyria commented Aug 11, 2022

e.g. here:

$zipArchive->assertContainsFilesExactly([
	'train.jpg' => ['size' => filesize(base_path(self::SAMPLE_FILE_TRAIN_IMAGE))],
	'mongolia-1.jpeg' => ['size' => filesize(base_path(self::SAMPLE_FILE_MONGOLIA_IMAGE))],
	'mongolia-2.jpeg' => ['size' => filesize(base_path(self::SAMPLE_FILE_MONGOLIA_IMAGE))],

Well mongalia-1, and mongolia-2 are not helping... but here for example makes a bit more sense:

$zipArchive->assertContainsFilesExactly([
	self::MULTI_BYTE_ALBUM_TITLE . '/fin de journée.jpg' => ['size' => filesize(base_path(TestCase::SAMPLE_FILE_SUNSET_IMAGE))],
	self::MULTI_BYTE_ALBUM_TITLE . '/mongolia.jpeg' => ['size' => filesize(base_path(TestCase::SAMPLE_FILE_MONGOLIA_IMAGE))],
]);

@nagmat84
Copy link
Collaborator Author

At these places such a helper function does not help. The name of downloaded file is not based on the original name of the initially uploaded file, but on the title of the photo which has been assigned by Lychee.

Copy link
Member

@ildyria ildyria left a comment

Choose a reason for hiding this comment

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

LGTM.

@ildyria ildyria added this to the 4.6.0 milestone Aug 11, 2022
tests/Feature/Lib/AssertableZipArchive.php Outdated Show resolved Hide resolved
Co-authored-by: Kamil Iskra <kamil.01482@iskra.name>
@nagmat84 nagmat84 merged commit bf09e72 into master Aug 11, 2022
@nagmat84 nagmat84 deleted the cleanup_tests branch August 11, 2022 21:22
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.

3 participants