-
Notifications
You must be signed in to change notification settings - Fork 20
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
E2E tests for torrent
routes
#121
E2E tests for torrent
routes
#121
Conversation
To submit multipart forms with reqwest. It'll be used in E2E tests.
It'll be used to store temporary torrent files for E2E tests.
It'll be used to generate unique identifiers for entities in E2E tests.
Create random torrent filesI needed to generate random torrents for the E2E tests. I found this repo: https://github.com/casey/intermodal. It's a command-line tool to generate torrents. I think it could be pretty helpful for testing all our BitTorrent-related projects. Unfortunately, they have not published a library yet (only the binary), but in this case, the wrapper is straightforward: fn create_torrent_file(dir: &Path, file_name: &str) -> PathBuf {
let input_file_path = Path::new(dir).join(file_name);
let output_file_path = Path::new(dir).join(format!("{file_name}.torrent"));
let output = Command::new("imdl")
.args(["torrent", "create", "--show"])
.args(["--input", &format!("{}", input_file_path.to_string_lossy())])
.args(["--output", &format!("{}", output_file_path.to_string_lossy())])
.output()
.expect("failed to create torrent file: {output_file_path}");
//io::stdout().write_all(&output.stdout).unwrap();
io::stderr().write_all(&output.stderr).unwrap();
output_file_path
} Since we use it for E2E testing, it's not a big problem. But for unit testing, having a system dependency would not be a good option. Extracting logic for torrent editionI think mods Autoincrement IDsIDs generated by the database are sometimes a pain because it makes it harder to write the asserts. For example, when you upload a torrent the response contains the ID. I'm going to add the infohash, so I can be sure the torrent was added to the index. In general, I think maybe using the infohash instead of those IDs would improve:
If we have cases where the infohash is not a real ID in our domain we could generate a UUID. Finally, I still have to add more tests to finish this PR. |
It'll be used to check if the command `imdl` is installed. It's needed in E2E tests to generate random torrents.
ACK e3ed344 |
E2E tests for API
torrent
routes.