diff options
Diffstat (limited to 'tests/units/test_index.rb')
-rw-r--r-- | tests/units/test_index.rb | 48 |
1 files changed, 48 insertions, 0 deletions
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 |