Page MenuHomeSoftware Heritage

Add test for content_get_range.
ClosedPublic

Authored by vlorentz on Jun 5 2019, 1:30 PM.

Diff Detail

Repository
rDSTO Storage manager
Branch
test-content_get_range
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 6603
Build 9215: tox-on-jenkinsJenkins
Build 9214: arc lint + arc unit

Event Timeline

douardda added inline comments.
swh/storage/tests/test_storage.py
3842

probably a stupid question but why do we expect 3 here (instead of 4)?

swh/storage/tests/test_storage.py
3842

Because we're getting contents in range get_sha1s[1] to get_sha1s[-1] inclusive, so that's all the contents (4) minus the first one.

swh/storage/tests/test_storage.py
3842

oh yes indeed.

Wouldn't it be useful (?) to raise the max_size and check the content_get_range against all situations wrt range limits: the beginning, middle and end of the range (like range(0, 2), range(n, n+2) and range(-3, -1) )?

swh/storage/tests/test_storage.py
3842

That's what the three tests are for (test_generate_content_get_range_start, test_generate_content_get_range_end, test_origin_get_range). I did not want to do a single test for all of them, because it means writing the same logic in the test as in the real code, so testing makes less sense

swh/storage/tests/test_storage.py
3842

Oh you mean I must read the whole diff when I review it? what a bama.

So now, why does the range_start test uses sha1[1] as start value?

swh/storage/tests/test_storage.py
3842

range_start tests that nothing before the start is returned, range_end tests that nothing after the end is returned.

3842

Eh, you're right, I could merge these two tests

Merge both tests, and use more input parameters to test all cases at once.

This revision is now accepted and ready to land.Jul 1 2019, 1:47 PM
This revision was landed with ongoing or failed builds.Jul 1 2019, 3:49 PM
This revision was automatically updated to reflect the committed changes.