@@ -475,7 +475,9 @@ defmodule Pinchflat.SlowIndexing.SlowIndexingHelpersTest do
475
475
end
476
476
477
477
describe "index_and_enqueue_download_for_media_items when testing the download archive" do
478
- test "a download archive is used if the source is a channel" , % { source: source } do
478
+ test "a download archive is used if the source is a channel that has been indexed before" do
479
+ source = source_fixture ( % { collection_type: :channel , last_indexed_at: now ( ) } )
480
+
479
481
expect ( YtDlpRunnerMock , :run , fn _url , :get_media_attributes_for_collection , opts , _ot , _addl_opts ->
480
482
assert :break_on_existing in opts
481
483
assert Keyword . has_key? ( opts , :download_archive )
@@ -499,6 +501,19 @@ defmodule Pinchflat.SlowIndexing.SlowIndexingHelpersTest do
499
501
SlowIndexingHelpers . index_and_enqueue_download_for_media_items ( source )
500
502
end
501
503
504
+ test "a download archive is not used if the source has never been indexed before" do
505
+ source = source_fixture ( % { collection_type: :channel , last_indexed_at: nil } )
506
+
507
+ expect ( YtDlpRunnerMock , :run , fn _url , :get_media_attributes_for_collection , opts , _ot , _addl_opts ->
508
+ refute :break_on_existing in opts
509
+ refute Keyword . has_key? ( opts , :download_archive )
510
+
511
+ { :ok , source_attributes_return_fixture ( ) }
512
+ end )
513
+
514
+ SlowIndexingHelpers . index_and_enqueue_download_for_media_items ( source )
515
+ end
516
+
502
517
test "a download archive is not used if the index has been forced to run" do
503
518
source = source_fixture ( % { collection_type: :channel } )
504
519
@@ -512,7 +527,9 @@ defmodule Pinchflat.SlowIndexing.SlowIndexingHelpersTest do
512
527
SlowIndexingHelpers . index_and_enqueue_download_for_media_items ( source , was_forced: true )
513
528
end
514
529
515
- test "the download archive is formatted correctly and contains the right video" , % { source: source } do
530
+ test "the download archive is formatted correctly and contains the right video" do
531
+ source = source_fixture ( % { collection_type: :channel , last_indexed_at: now ( ) } )
532
+
516
533
media_items =
517
534
1 .. 21
518
535
|> Enum . map ( fn n ->
0 commit comments