summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorscott Chacon <schacon@agadorsparticus.(none)>2007-11-11 10:04:26 -0800
committerscott Chacon <schacon@agadorsparticus.(none)>2007-11-11 10:04:26 -0800
commita1237671ba3ec38f5b123ee6600e4352dc03196b (patch)
tree71bc13cb36799e778237097b343a4d4fa9189b3f /tests
parentefcce7fc123b9e64fb9d93224e4e78d09144af3d (diff)
downloadthird_party-ruby-git-a1237671ba3ec38f5b123ee6600e4352dc03196b.zip
third_party-ruby-git-a1237671ba3ec38f5b123ee6600e4352dc03196b.tar.gz
third_party-ruby-git-a1237671ba3ec38f5b123ee6600e4352dc03196b.tar.xz
git add working, git status object working
Diffstat (limited to 'tests')
-rw-r--r--tests/units/test_config.rb7
-rw-r--r--tests/units/test_index.rb48
-rw-r--r--tests/units/test_init.rb1
3 files changed, 55 insertions, 1 deletions
diff --git a/tests/units/test_config.rb b/tests/units/test_config.rb
index 5adb391..66dc9ff 100644
--- a/tests/units/test_config.rb
+++ b/tests/units/test_config.rb
@@ -20,7 +20,12 @@ class TestBranch < Test::Unit::TestCase
end
def test_set_config
- # !! TODO !!
+ in_temp_dir do |path|
+ g = Git.clone(@wbare, 'bare')
+ assert_equal('scott Chacon', g.config('user.name'))
+ g.config('user.name', 'bully')
+ assert_equal('bully', g.config('user.name'))
+ end
end
end \ No newline at end of file
diff --git a/tests/units/test_index.rb b/tests/units/test_index.rb
new file mode 100644
index 0000000..cf20eaf
--- /dev/null
+++ b/tests/units/test_index.rb
@@ -0,0 +1,48 @@
+#!/usr/bin/env ruby
+
+require File.dirname(__FILE__) + '/../test_helper'
+
+class TestIndex< Test::Unit::TestCase
+
+ def setup
+ set_file_paths
+ @git = Git.open(@wdir)
+ end
+
+ def test_add
+ in_temp_dir do |path|
+ #puts path
+ g = Git.clone(@wbare, 'new')
+ Dir.chdir('new') do
+ assert_equal('100644', g.status['example.txt'].mode_index)
+ new_file('test-file', 'blahblahblah')
+ assert(g.status.untracked.assoc('test-file'))
+ g.add
+ assert(g.status.added.assoc('test-file'))
+ assert(!g.status.untracked.assoc('test-file'))
+ assert(!g.status.changed.assoc('example.txt'))
+ append_file('example.txt', 'hahahaha')
+ assert(g.status.changed.assoc('example.txt'))
+ g.add
+ assert(g.status.changed.assoc('example.txt'))
+ g.commit('my message')
+ assert(!g.status.changed.assoc('example.txt'))
+ assert(!g.status.added.assoc('test-file'))
+ assert(!g.status.untracked.assoc('test-file'))
+ end
+ end
+ end
+
+ def new_file(name, contents)
+ File.open(name, 'w') do |f|
+ f.puts contents
+ end
+ end
+
+ def append_file(name, contents)
+ File.open(name, 'a') do |f|
+ f.puts contents
+ end
+ end
+
+end \ No newline at end of file
diff --git a/tests/units/test_init.rb b/tests/units/test_init.rb
index 4681ba0..c192dc0 100644
--- a/tests/units/test_init.rb
+++ b/tests/units/test_init.rb
@@ -53,6 +53,7 @@ class TestInit < Test::Unit::TestCase
in_temp_dir do |path|
g = Git.clone(@wbare, 'bare-co')
assert(File.exists?(File.join(g.repo.path, 'config')))
+ assert(g.dir)
end
end