Add tags to torrent details in test responses#291
Add tags to torrent details in test responses#291josecelano merged 1 commit intotorrust:developfrom josecelano:issue-273add-tags-to-torrent-details-response-in-tests
Conversation
|
ACK 022692e |
|
Hi @da2ce7 @mario-nt, I've added the missing field in the struct. We should also include tags in the test torrents. For now, although it's included, it is an empty array. I haven't included any because there are no predefined tags as there are for categories, so the test must add the tag before building the test torrent. That requires a refactoring for the TestTorrent struct. Instead of building the test torrent with predefined values for the metadata (title, description, category and tags): fn build_from_torrent_file(id: &Uuid, torrent_path: &Path) -> TestTorrent {
// Load torrent binary file
let torrent_file = BinaryFile::from_file_at_path(torrent_path);
// Load torrent file metadata
let torrent_info = parse_torrent(torrent_path);
let torrent_to_index = TorrentIndexInfo {
title: format!("title-{id}"),
description: format!("description-{id}"),
category: software_category_name(),
// todo: include one tag in test torrents. Implementation is not
// trivial because the tag must exist in the database and there are
// no predefined tags in the database like there are for categories.
tags: None,
torrent_file,
name: contents_file_name(id),
};
TestTorrent {
file_info: torrent_info,
index_info: torrent_to_index,
}
}We should pass a struct with the values we want to use so that we can add the tag first in the test and later build the TestTorrent using that new tag. It's not a complex refactor, but I think we can create a new issue for that. It would also improve the code for building the test torrents. Maybe it's not a priority. I think having a test for uploading with all the form fields is a good thing and tags could be very important to organize and find torrents. So I would do it. |
In the tests the struct:
did not contain the torrent tags, so tests were not asserting that the tags were the expected ones.