54
54
self.assertEqualDiff(''.join(k.get_lines('text-1')), TEXT_1)
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))
334
334
self.assertEqual(k1.delta, k2.delta)
335
335
# the generic test checks for empty content and file class
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"
346
"revid fulltext 0 84 .a_ghost :",
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 :",
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 ')
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'))
339
374
Banana cup cakes: