red_oxide icon indicating copy to clipboard operation
red_oxide copied to clipboard

refactor: Split `command/transcode.rs` into discrete unit testable functions

Open RogueOneEcho opened this issue 1 month ago • 0 comments

Notes

This PR follows on from https://github.com/DevYukine/red_oxide/pull/26

I'm new to rust and figured refactoring an existing project would be a useful exercise to learn the language - as such I'd recommend a thorough review as there may obvious things I've missed or am not aware of.

As it's a significant revision I'd recommend reviewing it commit-by-commit as each is a discrete refactoring

Notable changes

Mostly the changes are just extracting logic but these are worth noting in particular:

  • [ ] https://github.com/DevYukine/red_oxide/commit/bc9083e7e928e28c35ecc59ed01e850df618a28b - changes the logic for how "has no FLAC base to transcode from... skipping" is determined.

Previous behaviour skipped if there was no existing FLAC release, but this change ensure the specified torrent is FLAC which seemed more logical.

  • [ ] https://github.com/DevYukine/red_oxide/commit/8b0aec4a72433215d7f314395102473bb3f1e832 - keeps TranscodeCommand as immutable and passes it by reference

This avoids partial moves without resorting to cloning and seems to be the more rust-like way of doing things

Testing

For the tests to work you will need to add some .flac files to samples/flacs/[TITLE]/[file_name].flac

To get tests running in CI some Open Source / Creative Commons could be downloaded and a mock api response created for them.

RogueOneEcho avatar May 19 '24 09:05 RogueOneEcho