Skip to content

Commit

Permalink
Add a unittest for repourl in Source
Browse files Browse the repository at this point in the history
  • Loading branch information
Benoit Allard authored and marcus-sonestedt committed Apr 7, 2010
1 parent 1a386f2 commit 56fba94
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions buildbot/test/unit/test_source_repourl.py
@@ -0,0 +1,37 @@
from twisted.trial import unittest

from buildbot.steps.source import Source

class SourceStamp(object):
repository = "test"

class Build(object):
s = SourceStamp()
def getSourceStamp(self):
return self.s

class RepoURL(unittest.TestCase):

def test_backward_compatibility(self):
s = Source()
s.build = Build()
self.assertEqual(s.computeRepositoryURL("repourl"), "repourl")

def test_format_string(self):
s = Source()
s.build = Build()
self.assertEquals(s.computeRepositoryURL("http://server/%s"), "http://server/test")

def test_dict(self):
s = Source()
s.build = Build()
dict = {}
dict['test'] = "ssh://server/testrepository"
self.assertEquals(s.computeRepositoryURL(dict), "ssh://server/testrepository")

def test_callable(self):
s = Source()
s.build = Build()
func = lambda x: x[::-1]
self.assertEquals(s.computeRepositoryURL(func), "tset")

1 comment on commit 56fba94

@djmitche
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hooray for tests!

Please sign in to comment.