GyrosOfWar / youtube-dl-rs

A youtube-dl wrapper for Rust
132 stars 40 forks source link

Tests Fail When Run Inside Docker Container #36

Closed beyse closed 1 year ago

beyse commented 1 year ago

Issue description

I want to use the crate inside a minimal docker container but the tests of this crate fail.

This also leads to a problem in other projects like this issue.

Steps to reproduce the issue

To reproduce you need docker installed in your machine.

  1. Clone this fork I created for this purpose: git clone https://github.com/beyse/youtube-dl-rs.git
  2. Build the docker image: docker build -t yt .
  3. Run a shell in the docker container: docker run -it --rm -v ${PWD}:/home/youtube-dl-rs yt /bin/bash
  4. You are now in the container, so you can build the project using cargo build
  5. Once that is done run the tests: cargo test

What's the expected result?

I would expect all tests to pass ✅

What's the actual result?

7 / 8 tests fail ❌

Additional details / screenshot

image

beyse commented 1 year ago

So it looks like the code in the crate makes some assumptions on the environment that are not fulfilled in a Docker container or the container I created is missing an important dependency or something.

GyrosOfWar commented 1 year ago

Hi, yeah, the tests require yt-dlp to be installed. See also the GitHub action file here (this one installs youtube-dl as well, but that's no longer necessary).

If you need the application to download to download yt-dlp by itself, you can use the built-in function (behind a feature flag), see this example

beyse commented 1 year ago

Alright, so I added pip and pip installed yt-dlp in my Dockerfile here and can confirm all tests pass ✅.

Thank you for your help @GyrosOfWar