changed a unit test
[rubygit.git] / tests / units / test_archive.rb
blob8824f5fe663a1c6f83ff36bec2b709122a25d414
1 #!/usr/bin/env ruby
3 require File.dirname(__FILE__) + '/../test_helper'
5 class TestArchive < Test::Unit::TestCase
6   
7   def setup
8     set_file_paths
9     @git = Git.open(@wdir)
10   end
11   
12   def tempfile
13     Tempfile.new('archive-test').path
14   end
15   
16   def test_archive
17     f = @git.archive('v2.6', tempfile)
18     assert(File.exists?(f))
20     f = @git.object('v2.6').archive(tempfile)  # writes to given file
21     assert(File.exists?(f))
23     f = @git.object('v2.6').archive # returns path to temp file
24     assert(File.exists?(f))
26     f = @git.object('v2.6').archive(tempfile, :format => 'zip')
27     assert(File.file?(f))
29     f = @git.object('v2.6').archive(tempfile, :format => 'tgz', :prefix => 'test/')
30     assert(File.exists?(f))
31     
32     f = @git.object('v2.6').archive(tempfile, :format => 'tar', :prefix => 'test/', :path => 'ex_dir/')
33     assert(File.exists?(f))
35     in_temp_dir do
36       c = Git.clone(@wbare, 'new')
37       c.chdir do
38         f = @git.remote('origin').branch('master').archive(tempfile, :format => 'tgz')
39         assert(File.exists?(f))
40       end
41     end
42   end
43   
44 end