test(ffmpeg): unit tests for core ffmpeg logic #8

Merged
dylan merged 13 commits from test/ffmpeg-unit-tests into master 2026-07-12 20:00:16 +01:00
2 changed files with 90 additions and 0 deletions
Showing only changes of commit bb6f5e7823 - Show all commits

View File

@@ -0,0 +1,48 @@
package com.ddf.vodsystem.services.media;
import com.ddf.vodsystem.dto.ProgressTracker;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import java.io.File;
import java.util.List;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify;
@ExtendWith(MockitoExtension.class)
class RemuxServiceTest {
@Mock
private CommandRunner commandRunner;
private RemuxService remuxService;
@BeforeEach
void setUp() {
remuxService = new RemuxService(commandRunner);
}
@Test
void remux_buildsExpectedFfmpegCommand() throws Exception {
File input = new File("videos/input.ts");
File output = new File("videos/output.mp4");
remuxService.remux(input, output, new ProgressTracker(), 60f);
verify(commandRunner).run(eq(List.of(
"ffmpeg",
"-progress", "pipe:1",
"-y",
"-i", input.getAbsolutePath(),
"-c:v", "h264",
"-c:a", "aac",
"-f", "mp4",
output.getAbsolutePath()
)), any());
}
}

View File

@@ -0,0 +1,42 @@
package com.ddf.vodsystem.services.media;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import java.nio.file.Path;
import java.util.List;
import static org.mockito.Mockito.verify;
@ExtendWith(MockitoExtension.class)
class ThumbnailServiceTest {
@Mock
private CommandRunner commandRunner;
private ThumbnailService thumbnailService;
@BeforeEach
void setUp() {
thumbnailService = new ThumbnailService(commandRunner);
}
@Test
void createThumbnail_buildsExpectedFfmpegCommand() throws Exception {
Path input = Path.of("videos/input.mp4");
Path output = Path.of("thumbnails/output.jpg");
thumbnailService.createThumbnail(input, output, 12.5f);
verify(commandRunner).run(List.of(
"ffmpeg",
"-ss", "12.5",
"-i", input.toAbsolutePath().toString(),
"-frames:v", "1",
output.toAbsolutePath().toString()
));
}
}