/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 breezy/plugins/git/tests/test_blackbox.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2018-05-18 20:50:10 UTC
  • mfrom: (6968.1.1 version-info-horizon)
  • Revision ID: breezy.the.bot@gmail.com-20180518205010-ozsv7xu743rsvn2t
Support 'brz version-info' in branches without a known revno.

Merged from https://code.launchpad.net/~jelmer/brz/version-info-horizon/+merge/345625

Show diffs side-by-side

added added

removed removed

Lines of Context:
275
275
        self.assertMultiLineEqual(out, b'')
276
276
        self.assertTrue(err.endswith, b'3 objects\n')
277
277
 
 
278
 
 
279
class ShallowTests(ExternalBase):
 
280
 
 
281
    def setUp(self):
 
282
        super(ShallowTests, self).setUp()
 
283
        # Smoke test for "bzr log" in a git repository with shallow depth.
 
284
        self.repo = GitRepo.init('gitr', mkdir=True)
 
285
        self.build_tree_contents([("gitr/foo", "hello from git")])
 
286
        self.repo.stage("foo")
 
287
        self.repo.do_commit(
 
288
                "message", committer="Somebody <user@example.com>",
 
289
                commit_timestamp=1526330165, commit_timezone=0,
 
290
                author_timestamp=1526330165, author_timezone=0,
 
291
                merge_heads=[b'aa' * 20])
 
292
 
278
293
    def test_log_shallow(self):
279
 
        # Smoke test for "bzr log" in a git repository with shallow depth.
280
 
        r = GitRepo.init('gitr', mkdir=True)
281
 
        self.build_tree_contents([("gitr/foo", "hello from git")])
282
 
        r.stage("foo")
283
 
        cid = r.do_commit("message", committer="Somebody <user@example.com>",
284
 
                    commit_timestamp=1526330165, commit_timezone=0,
285
 
                    author_timestamp=1526330165, author_timezone=0,
286
 
                    merge_heads=[b'aa' * 20])
287
 
 
288
294
        # Check that bzr log does not fail and includes the revision.
289
295
        output, error = self.run_bzr(['log', 'gitr'], retcode=3)
290
296
        self.assertEqual(error, 'brz: ERROR: Further revision history missing.\n')
291
297
        self.assertEqual(output,
292
298
                '------------------------------------------------------------\n'
293
 
                'revision-id: git-v1:' + cid + '\n'
294
 
                'git commit: ' + cid + '\n'
 
299
                'revision-id: git-v1:' + self.repo.head() + '\n'
 
300
                'git commit: ' + self.repo.head() + '\n'
295
301
                'committer: Somebody <user@example.com>\n'
296
302
                'timestamp: Mon 2018-05-14 20:36:05 +0000\n'
297
303
                'message:\n'
298
304
                '  message\n')
 
305
 
 
306
    def test_version_info_rio(self):
 
307
        output, error = self.run_bzr(['version-info', '--rio', 'gitr'])
 
308
        self.assertEqual(error, '')
 
309
        self.assertNotIn('revno:', output)
 
310
 
 
311
    def test_version_info_python(self):
 
312
        output, error = self.run_bzr(['version-info', '--python', 'gitr'])
 
313
        self.assertEqual(error, '')
 
314
        self.assertNotIn('revno:', output)
 
315
 
 
316
    def test_version_info_custom_with_revno(self):
 
317
        output, error = self.run_bzr(
 
318
                ['version-info', '--custom',
 
319
                 '--template=VERSION_INFO r{revno})\n', 'gitr'], retcode=3)
 
320
        self.assertEqual(error, 'brz: ERROR: Variable {revno} is not available.\n')
 
321
        self.assertEqual(output, 'VERSION_INFO r')
 
322
 
 
323
    def test_version_info_custom_without_revno(self):
 
324
        output, error = self.run_bzr(
 
325
                ['version-info', '--custom', '--template=VERSION_INFO \n',
 
326
                 'gitr'])
 
327
        self.assertEqual(error, '')
 
328
        self.assertEqual(output, 'VERSION_INFO \n')