Skip to content

Commit

Permalink
Add some tests for alwaysUseLatest.
Browse files Browse the repository at this point in the history
This catches the bugs fixed in
c303d10
and
95521c5
  • Loading branch information
tomprince committed Jan 24, 2012
1 parent d972f0c commit ebe76c0
Showing 1 changed file with 49 additions and 1 deletion.
50 changes: 49 additions & 1 deletion master/buildbot/test/unit/test_steps_source_oldsource_Source.py
Expand Up @@ -13,12 +13,13 @@
#
# Copyright Buildbot Team Members

import mock
from twisted.trial import unittest

from buildbot.interfaces import IRenderable
from buildbot.process.properties import Properties, WithProperties
from buildbot.steps.source import _ComputeRepositoryURL, Source
from buildbot.test.util import steps
from buildbot.test.util import steps, sourcesteps


class SourceStamp(object):
Expand Down Expand Up @@ -94,3 +95,50 @@ def test_constructor_args_lists(self):
descriptionDone=['svn', 'update'])
self.assertEqual(step.description, ['svn', 'update', '(running)'])
self.assertEqual(step.descriptionDone, ['svn', 'update'])

class TestSource(sourcesteps.SourceStepMixin, unittest.TestCase):

def setUp(self):
return self.setUpBuildStep()

def tearDown(self):
return self.tearDownBuildStep()

def test_start_alwaysUseLatest_True(self):
step = self.setupStep(Source(alwaysUseLatest=True),
{
'branch': 'other-branch',
'revision': 'revision',
},
patch = 'patch'
)
step.branch = 'branch'
step.startVC = mock.Mock()

step.startStep(mock.Mock())

self.assertEqual(step.startVC.call_args, (('branch', None, None), {}))

def test_start_alwaysUseLatest_False(self):
step = self.setupStep(Source(),
{
'branch': 'other-branch',
'revision': 'revision',
},
patch = 'patch'
)
step.branch = 'branch'
step.startVC = mock.Mock()

step.startStep(mock.Mock())

self.assertEqual(step.startVC.call_args, (('other-branch', 'revision', 'patch'), {}))

def test_start_alwaysUseLatest_False_no_branch(self):
step = self.setupStep(Source())
step.branch = 'branch'
step.startVC = mock.Mock()

step.startStep(mock.Mock())

self.assertEqual(step.startVC.call_args, (('branch', None, None), {}))

0 comments on commit ebe76c0

Please sign in to comment.