few hours work - diff is done
[rubygit.git] / tests / units / test_init.rb
blobf1a8ba414c7831f2f451922b8e3c0b17a6163ece
1 #!/usr/bin/env ruby
3 require File.dirname(__FILE__) + '/../test_helper'
5 class TestInit < Test::Unit::TestCase
6   def setup
7     set_file_paths
8   end
10   def test_open_simple
11     g = Git.open(@wdir)
12     assert_equal(g.dir.path, @wdir)
13     assert_equal(g.repo.path, File.join(@wdir, '.git'))
14     assert_equal(g.index.path, File.join(@wdir, '.git', 'index'))
15   end
16     
17   def test_open_opts 
18     g = Git.open @wdir, :repository => @wbare, :index => @index
19     assert_equal(g.repo.path, @wbare)
20     assert_equal(g.index.path, @index)
21   end
22   
23   def test_git_bare
24     g = Git.repo @wbare
25     assert_equal(g.repo.path, @wbare)
26   end
27   
28   #g = Git.init
29   #  Git.init('project')
30   #  Git.init('/home/schacon/proj', 
31   #             { :git_dir => '/opt/git/proj.git', 
32   #               :index_file => '/tmp/index'} )
33   def test_git_init
34     in_temp_dir do |path|
35       Git.init
36       assert(File.directory?(File.join(path, '.git')))
37       assert(File.exists?(File.join(path, '.git', 'config')))
38     end
39   end
40   
41   def test_git_init_remote_git
42     in_temp_dir do |dir|
43       assert(!File.exists?(File.join(dir, 'config')))
44       
45       in_temp_dir do |path|        
46         Git.init(path, :repository => dir)
47         assert(File.exists?(File.join(dir, 'config')))
48       end
49     end
50   end
51   
52   def test_git_clone
53     in_temp_dir do |path|      
54       Git.clone(uri, :repository => dir)
55       assert(File.exists?(File.join(dir, 'config')))
56     end
57   end
59   # trying to open a git project using a bare repo - rather than using Git.repo
60   def test_git_open_error
61     assert_raise ArgumentError do
62       g = Git.open @wbare
63     end
64   end
65   
66 end