@@ -69,7 +69,7 @@ defmodule Reencodarr.AbAv1.HelperTest do
6969 test "detects streams with attached_pic disposition" do
7070 file_path = "/media/movie_with_cover.mkv"
7171
72- ffprobe_response =
72+ ffprobe_with_images =
7373 Jason . encode! ( % {
7474 "streams" => [
7575 % {
@@ -86,11 +86,30 @@ defmodule Reencodarr.AbAv1.HelperTest do
8686 ]
8787 } )
8888
89+ ffprobe_clean =
90+ Jason . encode! ( % {
91+ "streams" => [
92+ % {
93+ "codec_name" => "hevc" ,
94+ "codec_type" => "video" ,
95+ "disposition" => % { "attached_pic" => 0 }
96+ }
97+ ]
98+ } )
99+
100+ counter = :counters . new ( 1 , [ :atomics ] )
89101 :meck . new ( System , [ :passthrough ] )
90102
91103 :meck . expect ( System , :cmd , fn
92- "ffprobe" , _ , _ -> { ffprobe_response , 0 }
93- "mkvpropedit" , _ , _ -> { "Done.\n " , 0 }
104+ "ffprobe" , _ , _ ->
105+ :counters . add ( counter , 1 , 1 )
106+
107+ if :counters . get ( counter , 1 ) == 1 ,
108+ do: { ffprobe_with_images , 0 } ,
109+ else: { ffprobe_clean , 0 }
110+
111+ "mkvpropedit" , _ , _ ->
112+ { "Done.\n " , 0 }
94113 end )
95114
96115 assert { :ok , ^ file_path } = Helper . clean_attachments ( file_path )
@@ -135,7 +154,7 @@ defmodule Reencodarr.AbAv1.HelperTest do
135154 test "calls mkvpropedit in-place for MKV with image attachments" do
136155 file_path = "/media/movie.mkv"
137156
138- ffprobe_response =
157+ ffprobe_with_images =
139158 Jason . encode! ( % {
140159 "streams" => [
141160 % {
@@ -152,11 +171,30 @@ defmodule Reencodarr.AbAv1.HelperTest do
152171 ]
153172 } )
154173
174+ ffprobe_clean =
175+ Jason . encode! ( % {
176+ "streams" => [
177+ % {
178+ "codec_name" => "hevc" ,
179+ "codec_type" => "video" ,
180+ "disposition" => % { "attached_pic" => 0 }
181+ }
182+ ]
183+ } )
184+
185+ counter = :counters . new ( 1 , [ :atomics ] )
155186 :meck . new ( System , [ :passthrough ] )
156187
157188 :meck . expect ( System , :cmd , fn
158- "ffprobe" , _ , _ -> { ffprobe_response , 0 }
159- "mkvpropedit" , [ ^ file_path | _ ] , _ -> { "Done.\n " , 0 }
189+ "ffprobe" , _ , _ ->
190+ :counters . add ( counter , 1 , 1 )
191+
192+ if :counters . get ( counter , 1 ) == 1 ,
193+ do: { ffprobe_with_images , 0 } ,
194+ else: { ffprobe_clean , 0 }
195+
196+ "mkvpropedit" , [ ^ file_path | _ ] , _ ->
197+ { "Done.\n " , 0 }
160198 end )
161199
162200 assert { :ok , ^ file_path } = Helper . clean_attachments ( file_path )
@@ -171,7 +209,7 @@ defmodule Reencodarr.AbAv1.HelperTest do
171209 test "does not create temp files for MKV attachment-only case" do
172210 file_path = "/media/movie.MKV"
173211
174- ffprobe_response =
212+ ffprobe_with_images =
175213 Jason . encode! ( % {
176214 "streams" => [
177215 % { "codec_name" => "hevc" , "codec_type" => "video" } ,
@@ -184,11 +222,30 @@ defmodule Reencodarr.AbAv1.HelperTest do
184222 ]
185223 } )
186224
225+ ffprobe_clean =
226+ Jason . encode! ( % {
227+ "streams" => [
228+ % {
229+ "codec_name" => "hevc" ,
230+ "codec_type" => "video" ,
231+ "disposition" => % { "attached_pic" => 0 }
232+ }
233+ ]
234+ } )
235+
236+ counter = :counters . new ( 1 , [ :atomics ] )
187237 :meck . new ( System , [ :passthrough ] )
188238
189239 :meck . expect ( System , :cmd , fn
190- "ffprobe" , _ , _ -> { ffprobe_response , 0 }
191- "mkvpropedit" , _ , _ -> { "Done.\n " , 0 }
240+ "ffprobe" , _ , _ ->
241+ :counters . add ( counter , 1 , 1 )
242+
243+ if :counters . get ( counter , 1 ) == 1 ,
244+ do: { ffprobe_with_images , 0 } ,
245+ else: { ffprobe_clean , 0 }
246+
247+ "mkvpropedit" , _ , _ ->
248+ { "Done.\n " , 0 }
192249 end )
193250
194251 { :ok , result_path } = Helper . clean_attachments ( file_path )
0 commit comments