Fix wrong media duration assertions and invalid tolerances

This commit is contained in:
Stefan Ceriu
2026-08-18 12:48:16 +03:00
parent 804fccf650
commit 5f49c25952
@@ -36,7 +36,7 @@ final class MediaUploadingPreprocessorTests {
#expect(audioURL.lastPathComponent == "test_audio.mp3")
#expect(audioInfo.mimetype == "audio/mpeg")
#expect(isEqual(audioInfo.duration ?? 0, 27, within: 100))
#expect(isEqual(audioInfo.duration ?? 0, 10.03, within: 0.1))
#expect(isEqual(audioInfo.size ?? 0, 194_811, within: 100))
}
@@ -67,7 +67,7 @@ final class MediaUploadingPreprocessorTests {
#expect(isEqual(videoInfo.size ?? 0, 4_016_620, within: 100))
#expect(videoInfo.width == 1280)
#expect(videoInfo.height == 720)
#expect(isEqual(videoInfo.duration ?? 0, 30, within: 100))
#expect(isEqual(videoInfo.duration ?? 0, 5.03, within: 0.1))
#expect(videoInfo.thumbnailInfo != nil)
#expect(videoInfo.thumbnailInfo?.mimetype == "image/jpeg")
@@ -96,7 +96,7 @@ final class MediaUploadingPreprocessorTests {
#expect(isEqual(optimizedVideoInfo.size ?? 0, 4_016_620, within: 100)) // Note: The video is already 720p so it doesn't change size.
#expect(optimizedVideoInfo.width == 1280)
#expect(optimizedVideoInfo.height == 720)
#expect(isEqual(optimizedVideoInfo.duration ?? 0, 30, within: 100))
#expect(isEqual(optimizedVideoInfo.duration ?? 0, 5.03, within: 0.1))
}
@Test(.timeLimit(.minutes(2))) // Transcoding videos can be slow on a busy CI runner.
@@ -126,7 +126,7 @@ final class MediaUploadingPreprocessorTests {
#expect(isEqual(videoInfo.size ?? 0, 2_004_134, within: 100))
#expect(videoInfo.width == 1080)
#expect(videoInfo.height == 1920)
#expect(isEqual(videoInfo.duration ?? 0, 21, within: 100))
#expect(isEqual(videoInfo.duration ?? 0, 3.07, within: 0.1))
#expect(videoInfo.thumbnailInfo != nil)
#expect(videoInfo.thumbnailInfo?.mimetype == "image/jpeg")
@@ -155,7 +155,7 @@ final class MediaUploadingPreprocessorTests {
#expect(isEqual(optimizedVideoInfo.size ?? 0, 3_779_866, within: 100)) // Note: This is slightly stupid because it is larger now 🤦‍♂️
#expect(optimizedVideoInfo.width == 720)
#expect(optimizedVideoInfo.height == 1280)
#expect(isEqual(optimizedVideoInfo.duration ?? 0, 30, within: 100))
#expect(isEqual(optimizedVideoInfo.duration ?? 0, 3.07, within: 0.1))
}
@Test