Skip to content

Commit

Permalink
Store tempfile objects to prevent deletion during tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bjfish committed Jan 5, 2022
1 parent 735b083 commit 272e3bc
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/units/test_archive.rb
Expand Up @@ -7,10 +7,16 @@ class TestArchive < Test::Unit::TestCase
def setup
set_file_paths
@git = Git.open(@wdir)
@tempfiles = []
end

def teardown
@tempfiles.clear
end

def tempfile
tempfile_object = Tempfile.new('archive-test')
@tempfiles << tempfile_object # prevent deletion until teardown
tempfile_object.close # close to avoid locking from git processes
tempfile_object.path
end
Expand Down

0 comments on commit 272e3bc

Please sign in to comment.