Merge "Add test facility to add file contents in github tests"
This commit is contained in:
commit
58b0b7b05e
|
@ -877,18 +877,17 @@ class FakeGithubPullRequest(object):
|
|||
repo.git.clean('-x', '-f', '-d')
|
||||
|
||||
if files:
|
||||
fn = files[0]
|
||||
self.files = files
|
||||
else:
|
||||
fn = '%s-%s' % (self.branch.replace('/', '_'), self.number)
|
||||
self.files = [fn]
|
||||
self.files = {fn: "test %s %s\n" % (self.branch, self.number)}
|
||||
msg = self.subject + '-' + str(self.number_of_commits)
|
||||
fn = os.path.join(repo.working_dir, fn)
|
||||
f = open(fn, 'w')
|
||||
with open(fn, 'w') as f:
|
||||
f.write("test %s %s\n" %
|
||||
(self.branch, self.number))
|
||||
repo.index.add([fn])
|
||||
for fn, content in self.files.items():
|
||||
fn = os.path.join(repo.working_dir, fn)
|
||||
f = open(fn, 'w')
|
||||
with open(fn, 'w') as f:
|
||||
f.write(content)
|
||||
repo.index.add([fn])
|
||||
|
||||
self.head_sha = repo.index.commit(msg).hexsha
|
||||
# Create an empty set of statuses for the given sha,
|
||||
|
|
|
@ -89,14 +89,14 @@ class TestGithubDriver(ZuulTestCase):
|
|||
def test_pull_matched_file_event(self):
|
||||
A = self.fake_github.openFakePullRequest(
|
||||
'org/project', 'master', 'A',
|
||||
files=['random.txt', 'build-requires'])
|
||||
files={'random.txt': 'test', 'build-requires': 'test'})
|
||||
self.fake_github.emitEvent(A.getPullRequestOpenedEvent())
|
||||
self.waitUntilSettled()
|
||||
self.assertEqual(1, len(self.history))
|
||||
|
||||
# test_pull_unmatched_file_event
|
||||
B = self.fake_github.openFakePullRequest('org/project', 'master', 'B',
|
||||
files=['random.txt'])
|
||||
files={'random.txt': 'test2'})
|
||||
self.fake_github.emitEvent(B.getPullRequestOpenedEvent())
|
||||
self.waitUntilSettled()
|
||||
self.assertEqual(1, len(self.history))
|
||||
|
|
Loading…
Reference in New Issue