From ef6828531b67b5e3d1bd3fb9e15bcdf63ab444be Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lo=C3=AFc=20Bersier?= <loic.bersier1@gmail.com>
Date: Sun, 13 Oct 2024 17:42:02 +0200
Subject: [PATCH] Test download util

---
 test/haha_yes_test.exs | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/test/haha_yes_test.exs b/test/haha_yes_test.exs
index 15f2768..877d4b3 100644
--- a/test/haha_yes_test.exs
+++ b/test/haha_yes_test.exs
@@ -1,8 +1,12 @@
 defmodule HahaYesTest do
   use ExUnit.Case
-  doctest HahaYes
+  doctest HahaYes.Utility
 
-  test "greets the world" do
-    assert HahaYes.hello() == :world
+  @tag :tmp_dir
+
+  test "download utils", %{tmp_dir: tmp_dir} do
+    assert HahaYes.Utility.download("https://x.com/i/status/1844841048603783249", "#{tmp_dir}/test") == {:ok, "#{tmp_dir}/test.mp4"}
+
+    assert HahaYes.Utility.download("invalid", "#{tmp_dir}/test") == {:error, "[generic] Extracting URL: invalid\nERROR: [generic] 'invalid' is not a valid URL. Set --default-search \"ytsearch\" (or run  yt-dlp \"ytsearch:invalid\" ) to search YouTube\n"}
   end
 end