~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_knit.py

  • Committer: Aaron Bentley
  • Date: 2006-04-13 18:20:57 UTC
  • mfrom: (1661 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1666.
  • Revision ID: abentley@panoramicfeedback.com-20060413182057-3ae84fef8ca8c67f
Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
        self.assertEqualDiff(''.join(k.get_lines('text-1')), TEXT_1)
55
55
 
56
56
    def test_knit_reload(self):
57
 
        """Store and reload a knit"""
 
57
        # test that the content in a reloaded knit is correct
58
58
        k = self.make_test_knit()
59
59
        k.add_lines('text-1', [], split_lines(TEXT_1))
60
60
        del k
334
334
        self.assertEqual(k1.delta, k2.delta)
335
335
        # the generic test checks for empty content and file class
336
336
 
 
337
    def test_knit_format(self):
 
338
        # this tests that a new knit index file has the expected content
 
339
        # and that is writes the data we expect as records are added.
 
340
        knit = self.make_test_knit(True)
 
341
        self.assertFileEqual("# bzr knit index 7\n", 'test.kndx')
 
342
        knit.add_lines_with_ghosts('revid', ['a_ghost'], ['a\n'])
 
343
        self.assertFileEqual(
 
344
            "# bzr knit index 7\n"
 
345
            "\n"
 
346
            "revid fulltext 0 84 .a_ghost :",
 
347
            'test.kndx')
 
348
        knit.add_lines_with_ghosts('revid2', ['revid'], ['a\n'])
 
349
        self.assertFileEqual(
 
350
            "# bzr knit index 7\n"
 
351
            "\nrevid fulltext 0 84 .a_ghost :"
 
352
            "\nrevid2 line-delta 84 82 0 :",
 
353
            'test.kndx')
 
354
        # we should be able to load this file again
 
355
        knit = KnitVersionedFile('test', LocalTransport('.'), access_mode='r')
 
356
        self.assertEqual(['revid', 'revid2'], knit.versions())
 
357
        # write a short write to the file and ensure that its ignored
 
358
        indexfile = file('test.kndx', 'at')
 
359
        indexfile.write('\nrevid3 line-delta 166 82 1 2 3 4 5 .phwoar:demo ')
 
360
        indexfile.close()
 
361
        # we should be able to load this file again
 
362
        knit = KnitVersionedFile('test', LocalTransport('.'), access_mode='w')
 
363
        self.assertEqual(['revid', 'revid2'], knit.versions())
 
364
        # and add a revision with the same id the failed write had
 
365
        knit.add_lines('revid3', ['revid2'], ['a\n'])
 
366
        # and when reading it revid3 should now appear.
 
367
        knit = KnitVersionedFile('test', LocalTransport('.'), access_mode='r')
 
368
        self.assertEqual(['revid', 'revid2', 'revid3'], knit.versions())
 
369
        self.assertEqual(['revid2'], knit.get_parents('revid3'))
 
370
 
 
371
 
337
372
 
338
373
TEXT_1 = """\
339
374
Banana cup cakes: