/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_knit.py

  • Committer: Robert Collins
  • Date: 2007-11-26 22:33:25 UTC
  • mto: This revision was merged to the branch mainline in revision 3033.
  • Revision ID: robertc@robertcollins.net-20071126223325-wua9x81prpxueom3
Don't include the pack container length in the lengths given by get_data_stream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2685
2685
            set(index.iter_parents(['tip'])))
2686
2686
        self.assertEqual(set(),
2687
2687
            set(index.iter_parents([])))
 
2688
 
 
2689
 
 
2690
class TestPackKnits(KnitTests):
 
2691
    """Tests that use a _PackAccess and KnitGraphIndex."""
 
2692
 
 
2693
    def test_get_data_stream_packs_ignores_pack_overhead(self):
 
2694
        # Packs have an encoding overhead that should not be included in the
 
2695
        # 'size' field of a data stream, because it is not returned by the
 
2696
        # raw_reading functions - it is why index_memo's are opaque, and
 
2697
        # get_data_stream was abusing this.
 
2698
        packname = 'test.pack'
 
2699
        transport = self.get_transport()
 
2700
        def write_data(bytes):
 
2701
            transport.append_bytes(packname, bytes)
 
2702
        writer = pack.ContainerWriter(write_data)
 
2703
        writer.begin()
 
2704
        index = InMemoryGraphIndex(2)
 
2705
        knit_index = KnitGraphIndex(index, add_callback=index.add_nodes,
 
2706
            deltas=True)
 
2707
        indices = {index:(transport, packname)}
 
2708
        access = _PackAccess(indices, writer=(writer, index))
 
2709
        k = KnitVersionedFile('test', get_transport('.'),
 
2710
            delta=True, create=True, index=knit_index, access_method=access)
 
2711
        # insert something into the knit
 
2712
        k.add_lines('text-1', [], ["foo\n"])
 
2713
        # get a data stream for it
 
2714
        stream = k.get_data_stream(['text-1'])
 
2715
        # if the stream has been incorrectly assembled, we will get a short read
 
2716
        # reading from the stream (as streams have no trailer)
 
2717
        expected_length = stream[1][0][2]
 
2718
        # we use -1 to do the read, so that if a trailer is added this test
 
2719
        # will fail and we'll adjust it to handle that case correctly, rather
 
2720
        # than allowing an over-read that is bogus.
 
2721
        self.assertEqual(expected_length, len(stream[2](-1)))