From c5fba6c44a608e370c35b6cdbe24b0cb555ae83f Mon Sep 17 00:00:00 2001 From: Marvin Pohl Date: Thu, 27 Sep 2018 16:53:16 +0200 Subject: [PATCH] Fixed unittest for Gitea source step --- buildbot_gitea/step_source.py | 11 ++++------- buildbot_gitea/test/test_step_source.py | 15 ++++++++++----- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/buildbot_gitea/step_source.py b/buildbot_gitea/step_source.py index 50c45f5..eca0d5f 100644 --- a/buildbot_gitea/step_source.py +++ b/buildbot_gitea/step_source.py @@ -16,13 +16,11 @@ class Gitea(Git): """ @defer.inlineCallbacks def _fetch(self, arg): - print("Update") - super(Gitea, self)._fetch(arg) + res = yield super(Gitea, self)._fetch(arg) if self.build.hasProperty("pr_id"): remote = yield self._dovccmd( ['config', 'remote.pr_source.url'], collectStdout=True) - print(remote) - if remote is None or remote is '': + if remote is None or remote.strip() is '': yield self._dovccmd( ['remote', 'add', 'pr_source', self.build.getProperty("head_git_ssh_url", None)]) @@ -31,6 +29,5 @@ class Gitea(Git): ['remote', 'set-url', 'pr_source', self.build.getProperty("head_git_ssh_url", None)]) yield self._dovccmd(['fetch', 'pr_source']) - yield self._dovccmd(['merge', self.build.getProperty("head_sha", None)]) - else: - print("Not a PR") + res = yield self._dovccmd(['merge', self.build.getProperty("head_sha", None)]) + defer.returnValue(res) \ No newline at end of file diff --git a/buildbot_gitea/test/test_step_source.py b/buildbot_gitea/test/test_step_source.py index 4978ca5..ba662fb 100644 --- a/buildbot_gitea/test/test_step_source.py +++ b/buildbot_gitea/test/test_step_source.py @@ -33,8 +33,8 @@ class TestGitea(sourcesteps.SourceStepMixin, config.ConfigErrorsMixin, unittest. self.sourceName = self.stepClass.__name__ return self.setUpSourceStep() - def setupStep(self, step, args, **kwargs): - step = sourcesteps.SourceStepMixin.setupStep(self, step, args, **kwargs) + def setupStep(self, step, **kwargs): + step = sourcesteps.SourceStepMixin.setupStep(self, step, **kwargs) step.build.properties.setProperty("pr_id", "1", "gitea pr id") step.build.properties.setProperty("base_sha", "f6ad368298bd941e934a41f3babc827b2aa95a1d", "gitea source branch") step.build.properties.setProperty("base_branch", "master", "gitea source branch") @@ -54,7 +54,7 @@ class TestGitea(sourcesteps.SourceStepMixin, config.ConfigErrorsMixin, unittest. def test_with_merge_branch(self): self.setupStep( Gitea(repourl='git@gitea.example.com:base/awesome_project.git', - mode='full', method='clean'), None) + mode='full', method='clean')) self.expectCommands( ExpectShell(workdir='wkdir', @@ -91,9 +91,14 @@ class TestGitea(sourcesteps.SourceStepMixin, config.ConfigErrorsMixin, unittest. + 0, ExpectShell(workdir='wkdir', command=['git', 'merge', 'e4cd1224c622d46a8199c85c858485723115d2c8']) - + 0 + + 0, + ExpectShell(workdir='wkdir', + command=['git', 'rev-parse', 'HEAD']) + + ExpectShell.log('stdio', + stdout='e4cd1224c622d46a8199c85c858485723115d2c8') + + 0, ) self.expectOutcome(result=SUCCESS) self.expectProperty( - 'got_revision', 'e4cd1224c622d46a8199c85c858485723115d2c8', 'GitLab') + 'got_revision', 'e4cd1224c622d46a8199c85c858485723115d2c8', 'Gitea') return self.runStep()