From 1b68ad3e55b287b8093624d5d52495f5030f5eeb Mon Sep 17 00:00:00 2001 From: Nico Rehwaldt Date: Thu, 11 Feb 2021 14:57:19 +0100 Subject: [PATCH] test: verify unknown merge error behavior --- test/fixtures/merge_error/004_status.json | 56 ++++++++++++++++ test/fixtures/merge_error/005_pulls.list.json | 65 ++++++++++++++++++ test/fixtures/merge_error/005a_pulls.get.json | 66 +++++++++++++++++++ .../fixtures/merge_error/005b_config.get.json | 12 ++++ .../006_repos.getBranchProtection.json | 20 ++++++ .../fixtures/merge_error/007_pulls.merge.json | 16 +++++ test/fixtures/merge_error/008_status.json | 56 ++++++++++++++++ test/index.test.js | 3 + 8 files changed, 294 insertions(+) create mode 100644 test/fixtures/merge_error/004_status.json create mode 100644 test/fixtures/merge_error/005_pulls.list.json create mode 100644 test/fixtures/merge_error/005a_pulls.get.json create mode 100644 test/fixtures/merge_error/005b_config.get.json create mode 100644 test/fixtures/merge_error/006_repos.getBranchProtection.json create mode 100644 test/fixtures/merge_error/007_pulls.merge.json create mode 100644 test/fixtures/merge_error/008_status.json diff --git a/test/fixtures/merge_error/004_status.json b/test/fixtures/merge_error/004_status.json new file mode 100644 index 0000000..567f57a --- /dev/null +++ b/test/fixtures/merge_error/004_status.json @@ -0,0 +1,56 @@ +{ + "name": "status", + "type": "event", + "payload": { + "sha": "53e4600f2c01d18a8005f0f3e857c701fed8a9e0", + "name": "nikku/testtest", + "context": "continuous-integration/travis-ci/push", + "state": "success", + "commit": { + "sha": "53e4600f2c01d18a8005f0f3e857c701fed8a9e0", + "commit": { + "author": { + "name": "Nico Rehwaldt" + }, + "committer": { + "name": "GitHub" + }, + "message": "Update test.txt", + "tree": { + "sha": "911f57504612def9e96f0991fc84d59e078ec674" + }, + "comment_count": 0 + }, + "author": { + "login": "nikku", + "type": "User" + }, + "committer": { + "login": "web-flow", + "type": "User" + }, + "parents": [ + { + "sha": "c5de67566cca3f699aab82e92dc930d964587f2a" + } + ] + }, + "branches": [ + { + "name": "nikku-patch-1", + "commit": { + "sha": "53e4600f2c01d18a8005f0f3e857c701fed8a9e0" + } + } + ], + "repository": { + "name": "testtest", + "full_name": "nikku/testtest", + "owner": { + "login": "nikku", + "type": "User" + }, + "default_branch": "master" + } + } +} \ No newline at end of file diff --git a/test/fixtures/merge_error/005_pulls.list.json b/test/fixtures/merge_error/005_pulls.list.json new file mode 100644 index 0000000..fbf285f --- /dev/null +++ b/test/fixtures/merge_error/005_pulls.list.json @@ -0,0 +1,65 @@ +{ + "name": "pulls.list", + "type": "api-call", + "args": { + "owner": "nikku", + "repo": "testtest", + "state": "open", + "head": "nikku:nikku-patch-1" + }, + "result": { + "data": [ + { + "number": 29, + "state": "open", + "title": "Update test.txt", + "user": { + "login": "nikku", + "type": "User" + }, + "merge_commit_sha": "2c249293b68269d009b489c978653101d055301e", + "assignees": [], + "requested_reviewers": [], + "requested_teams": [], + "labels": [], + "head": { + "label": "nikku:nikku-patch-1", + "ref": "nikku-patch-1", + "sha": "53e4600f2c01d18a8005f0f3e857c701fed8a9e0", + "user": { + "login": "nikku", + "type": "User" + }, + "repo": { + "name": "testtest", + "full_name": "nikku/testtest", + "owner": { + "login": "nikku", + "type": "User" + }, + "default_branch": "master" + } + }, + "base": { + "label": "nikku:master", + "ref": "master", + "sha": "c5de67566cca3f699aab82e92dc930d964587f2a", + "user": { + "login": "nikku", + "type": "User" + }, + "repo": { + "name": "testtest", + "full_name": "nikku/testtest", + "owner": { + "login": "nikku", + "type": "User" + }, + "default_branch": "master" + } + }, + "author_association": "OWNER" + } + ] + } +} \ No newline at end of file diff --git a/test/fixtures/merge_error/005a_pulls.get.json b/test/fixtures/merge_error/005a_pulls.get.json new file mode 100644 index 0000000..0b4a359 --- /dev/null +++ b/test/fixtures/merge_error/005a_pulls.get.json @@ -0,0 +1,66 @@ +{ + "name": "pulls.get", + "type": "api-call", + "args": { + "owner": "nikku", + "repo": "testtest", + "pull_number": 29 + }, + "result": { + "data": { + "rebaseable": true, + "mergeable": true, + "merged": false, + "draft": false, + "number": 29, + "state": "open", + "title": "Update test.txt", + "user": { + "login": "nikku", + "type": "User" + }, + "merge_commit_sha": "2c249293b68269d009b489c978653101d055301e", + "assignees": [], + "requested_reviewers": [], + "requested_teams": [], + "labels": [], + "head": { + "label": "nikku:nikku-patch-1", + "ref": "nikku-patch-1", + "sha": "53e4600f2c01d18a8005f0f3e857c701fed8a9e0", + "user": { + "login": "nikku", + "type": "User" + }, + "repo": { + "name": "testtest", + "full_name": "nikku/testtest", + "owner": { + "login": "nikku", + "type": "User" + }, + "default_branch": "master" + } + }, + "base": { + "label": "nikku:master", + "ref": "master", + "sha": "c5de67566cca3f699aab82e92dc930d964587f2a", + "user": { + "login": "nikku", + "type": "User" + }, + "repo": { + "name": "testtest", + "full_name": "nikku/testtest", + "owner": { + "login": "nikku", + "type": "User" + }, + "default_branch": "master" + } + }, + "author_association": "OWNER" + } + } +} \ No newline at end of file diff --git a/test/fixtures/merge_error/005b_config.get.json b/test/fixtures/merge_error/005b_config.get.json new file mode 100644 index 0000000..8e16b56 --- /dev/null +++ b/test/fixtures/merge_error/005b_config.get.json @@ -0,0 +1,12 @@ +{ + "name": "config.get", + "type": "api-call", + "args": { + "owner": "nikku", + "repo": "testtest", + "path": ".github/merge-me.yml" + }, + "result": { + "config": { } + } +} \ No newline at end of file diff --git a/test/fixtures/merge_error/006_repos.getBranchProtection.json b/test/fixtures/merge_error/006_repos.getBranchProtection.json new file mode 100644 index 0000000..a3eeea2 --- /dev/null +++ b/test/fixtures/merge_error/006_repos.getBranchProtection.json @@ -0,0 +1,20 @@ +{ + "name": "repos.getBranchProtection", + "type": "api-call", + "args": { + "owner": "nikku", + "repo": "testtest", + "branch": "master" + }, + "result": { + "data": { + "required_status_checks": { + "contexts": [ + "Travis CI - Pull Request" + ] + }, + "required_pull_request_reviews": {}, + "enforce_admins": {} + } + } +} \ No newline at end of file diff --git a/test/fixtures/merge_error/007_pulls.merge.json b/test/fixtures/merge_error/007_pulls.merge.json new file mode 100644 index 0000000..03d916d --- /dev/null +++ b/test/fixtures/merge_error/007_pulls.merge.json @@ -0,0 +1,16 @@ +{ + "name": "pulls.merge", + "type": "api-call", + "args": { + "owner": "nikku", + "repo": "testtest", + "pull_number": 29, + "sha": "53e4600f2c01d18a8005f0f3e857c701fed8a9e0", + "merge_method": "rebase" + }, + "result": { + "error": { + "message": "intended failure" + } + } +} \ No newline at end of file diff --git a/test/fixtures/merge_error/008_status.json b/test/fixtures/merge_error/008_status.json new file mode 100644 index 0000000..636c3e7 --- /dev/null +++ b/test/fixtures/merge_error/008_status.json @@ -0,0 +1,56 @@ +{ + "name": "status", + "type": "event", + "payload": { + "sha": "53e4600f2c01d18a8005f0f3e857c701fed8a9e0", + "name": "nikku/testtest", + "context": "continuous-integration/travis-ci/pr", + "state": "pending", + "commit": { + "sha": "53e4600f2c01d18a8005f0f3e857c701fed8a9e0", + "commit": { + "author": { + "name": "Nico Rehwaldt" + }, + "committer": { + "name": "GitHub" + }, + "message": "Update test.txt", + "tree": { + "sha": "911f57504612def9e96f0991fc84d59e078ec674" + }, + "comment_count": 0 + }, + "author": { + "login": "nikku", + "type": "User" + }, + "committer": { + "login": "web-flow", + "type": "User" + }, + "parents": [ + { + "sha": "c5de67566cca3f699aab82e92dc930d964587f2a" + } + ] + }, + "branches": [ + { + "name": "nikku-patch-1", + "commit": { + "sha": "53e4600f2c01d18a8005f0f3e857c701fed8a9e0" + } + } + ], + "repository": { + "name": "testtest", + "full_name": "nikku/testtest", + "owner": { + "login": "nikku", + "type": "User" + }, + "default_branch": "master" + } + } +} \ No newline at end of file diff --git a/test/index.test.js b/test/index.test.js index 8ec5f3f..203a6d5 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -92,6 +92,9 @@ describe('bot', function() { // mergeMethod is it('should handle config errors', test('config_errors')); + + it('should handle merge error', test('merge_error')); + });