Skip to content

Commit

Permalink
#1833 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
qdraw committed Jan 22, 2025
1 parent 52915e8 commit 347326c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions starsky/starsky.foundation.video/Process/VideoProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ public async Task<VideoResult> RunVideo(string subPath,
if ( downloadStatus != FfmpegDownloadStatus.Ok )
{
_logger.LogDebug("[VideoProcess] FFMpeg download failed");
return ( new VideoResult(false, null, "FFMpeg download failed"), Stream.Null );
return ( new VideoResult(false, null,
"FFMpeg download failed"), Stream.Null );
}

var sourceStream = _storage.ReadStream(subPath, maxRead);
var ffmpegPath = _ffMpegDownload.GetSetFfMpegPath();

var runner =
new FfmpegStreamToStreamRunner(_ffMpegDownload.GetSetFfMpegPath(), sourceStream,
_logger);
var runner = new FfmpegStreamToStreamRunner(ffmpegPath, sourceStream, _logger);
var (stream, success) =
await runner.RunProcessAsync(ffmpegInputArguments, outputFormat, subPath);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,10 @@ public FfmpegStreamToStreamRunnerTests()

}

private void CreateStubFile(string path, string content)
private async Task CreateStubFile(string path, string content)
{
var stream = StringToStreamHelper.StringToStream(content);
_hostFullPathFilesystem.WriteStream(stream, path);
stream.Dispose();
stream.Close();
await _hostFullPathFilesystem.WriteStreamAsync(stream, path);
}

private async Task<string> SetupFakeFfmpegExecutable(int i)
Expand All @@ -57,9 +55,9 @@ private async Task<string> SetupFakeFfmpegExecutable(int i)
new CreateAnZipfileFakeFfMpeg().Bytes
]);

CreateStubFile(_ffmpegExePosix,
await CreateStubFile(_ffmpegExePosix,
"#!/bin/bash\necho Fake Executable");
CreateStubFile(readFile + i, "test_content");
await CreateStubFile(readFile + i, "test_content");

var ffmpegExe = new MemoryStream(zipper.FirstOrDefault(p =>
p.Key == "ffmpeg.exe").Value);
Expand Down Expand Up @@ -92,14 +90,15 @@ public static void CleanUp()
public async Task RunProcessAsync_HappyFlow()
{
var readFile = await SetupFakeFfmpegExecutable(0);

var file = new StorageHostFullPathFilesystem(new FakeIWebLogger()).ReadStream(readFile);
var sut = new FfmpegStreamToStreamRunner(_ffmpegExe, file, new FakeIWebLogger());

var hostStorage = new StorageHostFullPathFilesystem(new FakeIWebLogger());
var sourceStream = hostStorage.ReadStream(readFile);
var sut = new FfmpegStreamToStreamRunner(_ffmpegExe, sourceStream, new FakeIWebLogger());

var (stream, result) = await sut.RunProcessAsync("-1",
"image2", "test");

await file.DisposeAsync();
await sourceStream.DisposeAsync();

Assert.IsNotNull(stream);
Assert.IsTrue(result);
Expand All @@ -119,7 +118,7 @@ public async Task RunProcessAsync_ExitCode()
var readFile = await SetupFakeFfmpegExecutable(1);

// overwrite the file with a bash script that will exit with code 1
CreateStubFile(_ffmpegExePosix,
await CreateStubFile(_ffmpegExePosix,
"#!/bin/bash\ntest_content\n exit 1");

var file = new StorageHostFullPathFilesystem(new FakeIWebLogger()).ReadStream(readFile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public void CleanUpVideoProcessTests()
public async Task RunVideo_Default_False()
{
var result = await _videoProcess.RunVideo("/test",
"beforeFileHash", VideoProcessTypesTests.InvalidEnum());
"beforeFileHash",
VideoProcessTypesTests.InvalidEnum());
Assert.IsFalse(result.IsSuccess);
}

Expand Down

0 comments on commit 347326c

Please sign in to comment.