Skip to content

Add tags to torrent details in test responses#291

Merged
josecelano merged 1 commit intotorrust:developfrom
josecelano:issue-273add-tags-to-torrent-details-response-in-tests
Sep 14, 2023
Merged

Add tags to torrent details in test responses#291
josecelano merged 1 commit intotorrust:developfrom
josecelano:issue-273add-tags-to-torrent-details-response-in-tests

Conversation

@josecelano
Copy link
Copy Markdown
Member

In the tests the struct:

pub struct TorrentDetails {
    pub torrent_id: Id,
    pub uploader: String,
    pub info_hash: String,
    pub title: String,
    pub description: String,
    pub category: Category,
    pub upload_date: UtcDateTime,
    pub file_size: u64,
    pub seeders: u64,
    pub leechers: u64,
    pub files: Vec<File>,
    pub trackers: Vec<String>,
    pub magnet_link: String,
}

did not contain the torrent tags, so tests were not asserting that the tags were the expected ones.

@josecelano josecelano temporarily deployed to coverage September 14, 2023 12:46 — with GitHub Actions Inactive
@josecelano josecelano linked an issue Sep 14, 2023 that may be closed by this pull request
@josecelano josecelano temporarily deployed to coverage September 14, 2023 12:47 — with GitHub Actions Inactive
@josecelano
Copy link
Copy Markdown
Member Author

ACK 022692e

@josecelano
Copy link
Copy Markdown
Member Author

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.

@josecelano josecelano requested a review from da2ce7 September 14, 2023 12:57
@josecelano josecelano merged commit cbe1fc3 into torrust:develop Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Tags field missing in TorrentDetails (test) struct

1 participant