~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to tests.py

  • Committer: Michael Ellerman
  • Date: 2005-10-26 10:45:38 UTC
  • mto: (0.3.1 shelf-dev) (325.1.2 bzrtools)
  • mto: This revision was merged to the branch mainline in revision 246.
  • Revision ID: michael@ellerman.id.au-20051026104538-845c51008fecc9d1
Update test with revision to actually test the shelf worked properly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
    ORIGINAL = '\n\nhello test world\n\n'
7
7
    MODIFIED = '\n\ngoodbye test world\n\n'
8
8
    DIFF_HEADER = "=== modified file 'test_file'\n"
9
 
    DIFF = """--- test_file
 
9
    DIFF_1 = """--- test_file
10
10
+++ test_file
11
11
@@ -1,4 +1,4 @@
12
12
 
15
15
+goodbye test world
16
16
 
17
17
"""
 
18
    DIFF_2 = """--- test_file
 
19
+++ test_file
 
20
@@ -1,4 +1,4 @@
 
21
 
 
22
 
 
23
-goodbye test world
 
24
+hello test world
 
25
 
 
26
"""
18
27
    def test_shelf(self):
19
28
        from bzrlib.branch import Branch
20
29
        b = Branch.initialize('.')
29
38
 
30
39
        # Check the diff is right
31
40
        self.assertEqual(self.capture('diff'),
32
 
            self.DIFF_HEADER + self.DIFF + '\n')
 
41
            self.DIFF_HEADER + self.DIFF_1 + '\n')
33
42
 
34
43
        # Shelve the changes
35
44
        self.run_bzr('shelve', '--all', retcode=True)
42
51
 
43
52
        # Check the shelf is right
44
53
        shelf = file('.bzr-shelf').read()
45
 
        self.assertEqual(shelf, self.DIFF)
 
54
        self.assertEqual(shelf, self.DIFF_1)
46
55
 
47
56
        # Unshelve
48
57
        self.run_bzr('unshelve', retcode=True)
49
58
 
50
59
        # Check the diff is right again
51
60
        self.assertEqual(self.capture('diff'),
52
 
            self.DIFF_HEADER + self.DIFF + '\n')
 
61
            self.DIFF_HEADER + self.DIFF_1 + '\n')
53
62
 
54
63
        # Make sure the file is back the way it should be
55
64
        self.assertEqual(file('test_file').read(), self.MODIFIED)
86
95
        # Shelve the changes
87
96
        self.run_bzr('shelve', '-r', '1', '--all', retcode=True)
88
97
 
 
98
        # Check the diff is right
 
99
        self.assertEqual(self.capture('diff'),
 
100
            self.DIFF_HEADER + self.DIFF_2 + '\n')
 
101
 
 
102
        # Make sure the file is the way it should be
 
103
        self.assertEqual(file('test_file').read(), self.ORIGINAL)
 
104
 
 
105
        # Unshelve
 
106
        self.run_bzr('unshelve', retcode=True)
 
107
 
 
108
        # Make sure the file is back the way it should be
 
109
        self.assertEqual(file('test_file').read(), self.MODIFIED)
 
110
 
89
111
    def test_shelf_with_two_revisions(self):
90
112
        from bzrlib.branch import Branch
91
113
        b = Branch.initialize('.')