Skip to content

Commit

Permalink
update testing
Browse files Browse the repository at this point in the history
  • Loading branch information
MilesPurvis committed Oct 18, 2024
1 parent 7aac56a commit e0dc561
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.3.0
3.3.4
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ruby '3.3.0'
ruby '3.3.4'
source "https://rubygems.org"

gem 'rubocop'
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ DEPENDENCIES
rubocop

RUBY VERSION
ruby 3.3.0p0
ruby 3.3.4p94

BUNDLED WITH
2.4.12
12 changes: 8 additions & 4 deletions lib/ffmpeg/transcoder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def run(&)
end

def encoding_succeeded?
# failing test
@errors << "no output file created" and return false unless File.exist?(@output_file)
@errors << "encoded file is invalid" and return false unless encoded.valid?
true
Expand Down Expand Up @@ -206,10 +207,13 @@ def transcode_movie
raise Error, "Process hung. Full output: #{@output}"
end
end
# copy temp output file to original output file
FileUtils.cp(temp_output_file, @output_file)
# delete temp output file
FileUtils.rm_rf(temp_output_file, secure: true)
begin
FileUtils.cp(temp_output_file, @output_file)
rescue Errno::ENOENT
raise FFMPEG::Error, "no output file created"
ensure
FileUtils.rm_rf(temp_output_file, secure: true)
end
end

def validate_output_file(&block)
Expand Down
5 changes: 4 additions & 1 deletion spec/ffmpeg/transcoder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ module FFMPEG
end

it "should transcode the movie with progress given an awesome movie" do
FileUtils.rm_f "#{tmp_path}/awesome.flv"
output_file = "#{tmp_path}/awesome_#{SecureRandom.urlsafe_base64}.flv"
FileUtils.rm_f output_file

transcoder = Transcoder.new(movie, "#{tmp_path}/awesome.flv")
progress_updates = []
Expand Down Expand Up @@ -214,6 +215,7 @@ module FFMPEG

pending "should not crash on ISO-8859-1 characters (dont know how to spec this)"

# failing test
it "should fail when given an invalid movie" do
expect(FFMPEG.logger).to receive(:error).at_least(:once)
movie = Movie.new(__FILE__)
Expand Down Expand Up @@ -283,6 +285,7 @@ module FFMPEG
FFMPEG.ffmpeg_binary = "#{fixture_path}/bin/ffmpeg-audio-only"
end

# failing test
it "should not fail when the timeout is exceeded" do
transcoder = Transcoder.new(movie, "#{tmp_path}/timeout.mp4")
# Would expect to raise (FFMPEG::Error, /Process hung/) before this
Expand Down

0 comments on commit e0dc561

Please sign in to comment.