File: test_stashes.rb

package info (click to toggle)
ruby-git 1.13.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 4,124 kB
  • sloc: ruby: 5,385; sh: 507; perl: 64; makefile: 6
file content (58 lines) | stat: -rw-r--r-- 1,408 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env ruby

require File.dirname(__FILE__) + '/../test_helper'

class TestStashes < Test::Unit::TestCase
  def setup
    set_file_paths
  end
  
  def test_stash_unstash
    in_temp_dir do |path|
      g = Git.clone(@wbare, 'stash_test')
      Dir.chdir('stash_test') do
        assert_equal(0, g.branch.stashes.size)
        new_file('test-file1', 'blahblahblah1')
        new_file('test-file2', 'blahblahblah2')
        assert(g.status.untracked.assoc('test-file1'))

        g.add

        assert(g.status.added.assoc('test-file1'))
      
        g.branch.stashes.save('testing')
      
        g.reset
        assert_nil(g.status.untracked.assoc('test-file1'))
        assert_nil(g.status.added.assoc('test-file1'))

        g.branch.stashes.apply

        assert(g.status.added.assoc('test-file1'))
      end
    end
  end

  def test_stashes_all
    in_temp_dir do |path|
      g = Git.clone(@wbare, 'stash_test')
      Dir.chdir('stash_test') do
        assert_equal(0, g.branch.stashes.size)
        new_file('test-file1', 'blahblahblah1')
        new_file('test-file2', 'blahblahblah2')
        assert(g.status.untracked.assoc('test-file1'))

        g.add

        assert(g.status.added.assoc('test-file1'))

        g.branch.stashes.save('testing-stash-all')

        stashes = g.branch.stashes.all

        assert(stashes[0].include?('testing-stash-all'))
      end
    end
  end
  
end