Skip to content

Commit

Permalink
Add basic server tests for mentions.
Browse files Browse the repository at this point in the history
  • Loading branch information
ehuss committed Feb 21, 2023
1 parent 7b98215 commit 68e214c
Show file tree
Hide file tree
Showing 40 changed files with 4,243 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/server_test/mentions.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
use super::run_test;

#[test]
fn default_mention() {
// A new PR that touches a file in the [mentions] config with the default
// message.
run_test("mentions/default_mention");
}

#[test]
fn custom_message() {
// A new PR that touches a file in the [mentions] config with a custom
// message.
run_test("mentions/custom_message");
}

#[test]
fn dont_mention_twice() {
// When pushing modifications to the same files, don't mention again.
//
// However if a push comes in for a different file, make sure it mentions again.
//
// This starts with a new PR adding example2/README.md.
// It then pushes an update to example2/README.md.
// And then a second update to add example1/README.md.
run_test("mentions/dont_mention_twice");
}
492 changes: 492 additions & 0 deletions tests/server_test/mentions/custom_message/00-webhook-pr83_opened.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"kind": "Request",
"method": "GET",
"path": "/ehuss/triagebot-test/main/triagebot.toml",
"query": null,
"request_body": "",
"response_code": 200,
"response_body": "[mentions.'foo/example1']\ncc = [\"@grashgal\", \"@ehuss\"]\n\n[mentions.'foo/example2']\ncc = [\"@grashgal\", \"@ehuss\"]\nmessage = \"a custom message\"\n"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"kind": "Request",
"method": "GET",
"path": "/repos/ehuss/triagebot-test/compare/c4b85555a1e9aa18e15fe8bce84a4f1f8cd9e517...54d331809db68eeedbd425d0bc3e5fec2a6c5c9e",
"query": null,
"request_body": "",
"response_code": 200,
"response_body": "diff --git a/foo/example2/README.md b/foo/example2/README.md\nnew file mode 100644\nindex 0000000..4dca9fb\n--- /dev/null\n+++ b/foo/example2/README.md\n@@ -0,0 +1,2 @@\n+# Example2\n+\n"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"kind": "Request",
"method": "POST",
"path": "/repos/ehuss/triagebot-test/issues/83/comments",
"query": null,
"request_body": "{\"body\":\"a custom message\\n\\ncc @grashgal, @ehuss\"}",
"response_code": 201,
"response_body": {
"author_association": "OWNER",
"body": "a custom message\n\ncc @grashgal, @ehuss",
"created_at": "2023-02-20T19:53:31Z",
"html_url": "https://github.com/ehuss/triagebot-test/pull/83#issuecomment-1437486668",
"id": 1437486668,
"issue_url": "https://api.github.com/repos/ehuss/triagebot-test/issues/83",
"node_id": "IC_kwDOHkK3Xc5Vrk5M",
"performed_via_github_app": null,
"reactions": {
"+1": 0,
"-1": 0,
"confused": 0,
"eyes": 0,
"heart": 0,
"hooray": 0,
"laugh": 0,
"rocket": 0,
"total_count": 0,
"url": "https://api.github.com/repos/ehuss/triagebot-test/issues/comments/1437486668/reactions"
},
"updated_at": "2023-02-20T19:53:31Z",
"url": "https://api.github.com/repos/ehuss/triagebot-test/issues/comments/1437486668",
"user": {
"avatar_url": "https://avatars.githubusercontent.com/u/43198?u=4e88d47bc79d87f09f463582681d29f1ed6f478e&v=4",
"events_url": "https://api.github.com/users/ehuss/events{/privacy}",
"followers_url": "https://api.github.com/users/ehuss/followers",
"following_url": "https://api.github.com/users/ehuss/following{/other_user}",
"gists_url": "https://api.github.com/users/ehuss/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/ehuss",
"id": 43198,
"login": "ehuss",
"node_id": "MDQ6VXNlcjQzMTk4",
"organizations_url": "https://api.github.com/users/ehuss/orgs",
"received_events_url": "https://api.github.com/users/ehuss/received_events",
"repos_url": "https://api.github.com/users/ehuss/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/ehuss/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/ehuss/subscriptions",
"type": "User",
"url": "https://api.github.com/users/ehuss"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"kind": "Request",
"method": "GET",
"path": "/v1/teams.json",
"query": null,
"request_body": "",
"response_code": 200,
"response_body": null
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,239 @@
{
"kind": "Webhook",
"webhook_event": "issue_comment",
"payload": {
"action": "created",
"comment": {
"author_association": "OWNER",
"body": "a custom message\n\ncc @grashgal, @ehuss",
"created_at": "2023-02-20T19:53:31Z",
"html_url": "https://github.com/ehuss/triagebot-test/pull/83#issuecomment-1437486668",
"id": 1437486668,
"issue_url": "https://api.github.com/repos/ehuss/triagebot-test/issues/83",
"node_id": "IC_kwDOHkK3Xc5Vrk5M",
"performed_via_github_app": null,
"reactions": {
"+1": 0,
"-1": 0,
"confused": 0,
"eyes": 0,
"heart": 0,
"hooray": 0,
"laugh": 0,
"rocket": 0,
"total_count": 0,
"url": "https://api.github.com/repos/ehuss/triagebot-test/issues/comments/1437486668/reactions"
},
"updated_at": "2023-02-20T19:53:31Z",
"url": "https://api.github.com/repos/ehuss/triagebot-test/issues/comments/1437486668",
"user": {
"avatar_url": "https://avatars.githubusercontent.com/u/43198?v=4",
"events_url": "https://api.github.com/users/ehuss/events{/privacy}",
"followers_url": "https://api.github.com/users/ehuss/followers",
"following_url": "https://api.github.com/users/ehuss/following{/other_user}",
"gists_url": "https://api.github.com/users/ehuss/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/ehuss",
"id": 43198,
"login": "ehuss",
"node_id": "MDQ6VXNlcjQzMTk4",
"organizations_url": "https://api.github.com/users/ehuss/orgs",
"received_events_url": "https://api.github.com/users/ehuss/received_events",
"repos_url": "https://api.github.com/users/ehuss/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/ehuss/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/ehuss/subscriptions",
"type": "User",
"url": "https://api.github.com/users/ehuss"
}
},
"issue": {
"active_lock_reason": null,
"assignee": null,
"assignees": [],
"author_association": "OWNER",
"body": null,
"closed_at": null,
"comments": 1,
"comments_url": "https://api.github.com/repos/ehuss/triagebot-test/issues/83/comments",
"created_at": "2023-02-20T19:53:29Z",
"draft": false,
"events_url": "https://api.github.com/repos/ehuss/triagebot-test/issues/83/events",
"html_url": "https://github.com/ehuss/triagebot-test/pull/83",
"id": 1592371920,
"labels": [],
"labels_url": "https://api.github.com/repos/ehuss/triagebot-test/issues/83/labels{/name}",
"locked": false,
"milestone": null,
"node_id": "PR_kwDOHkK3Xc5KXzp4",
"number": 83,
"performed_via_github_app": null,
"pull_request": {
"diff_url": "https://github.com/ehuss/triagebot-test/pull/83.diff",
"html_url": "https://github.com/ehuss/triagebot-test/pull/83",
"merged_at": null,
"patch_url": "https://github.com/ehuss/triagebot-test/pull/83.patch",
"url": "https://api.github.com/repos/ehuss/triagebot-test/pulls/83"
},
"reactions": {
"+1": 0,
"-1": 0,
"confused": 0,
"eyes": 0,
"heart": 0,
"hooray": 0,
"laugh": 0,
"rocket": 0,
"total_count": 0,
"url": "https://api.github.com/repos/ehuss/triagebot-test/issues/83/reactions"
},
"repository_url": "https://api.github.com/repos/ehuss/triagebot-test",
"state": "open",
"state_reason": null,
"timeline_url": "https://api.github.com/repos/ehuss/triagebot-test/issues/83/timeline",
"title": "Add example2 file.",
"updated_at": "2023-02-20T19:53:31Z",
"url": "https://api.github.com/repos/ehuss/triagebot-test/issues/83",
"user": {
"avatar_url": "https://avatars.githubusercontent.com/u/43198?v=4",
"events_url": "https://api.github.com/users/ehuss/events{/privacy}",
"followers_url": "https://api.github.com/users/ehuss/followers",
"following_url": "https://api.github.com/users/ehuss/following{/other_user}",
"gists_url": "https://api.github.com/users/ehuss/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/ehuss",
"id": 43198,
"login": "ehuss",
"node_id": "MDQ6VXNlcjQzMTk4",
"organizations_url": "https://api.github.com/users/ehuss/orgs",
"received_events_url": "https://api.github.com/users/ehuss/received_events",
"repos_url": "https://api.github.com/users/ehuss/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/ehuss/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/ehuss/subscriptions",
"type": "User",
"url": "https://api.github.com/users/ehuss"
}
},
"repository": {
"allow_forking": true,
"archive_url": "https://api.github.com/repos/ehuss/triagebot-test/{archive_format}{/ref}",
"archived": false,
"assignees_url": "https://api.github.com/repos/ehuss/triagebot-test/assignees{/user}",
"blobs_url": "https://api.github.com/repos/ehuss/triagebot-test/git/blobs{/sha}",
"branches_url": "https://api.github.com/repos/ehuss/triagebot-test/branches{/branch}",
"clone_url": "https://github.com/ehuss/triagebot-test.git",
"collaborators_url": "https://api.github.com/repos/ehuss/triagebot-test/collaborators{/collaborator}",
"comments_url": "https://api.github.com/repos/ehuss/triagebot-test/comments{/number}",
"commits_url": "https://api.github.com/repos/ehuss/triagebot-test/commits{/sha}",
"compare_url": "https://api.github.com/repos/ehuss/triagebot-test/compare/{base}...{head}",
"contents_url": "https://api.github.com/repos/ehuss/triagebot-test/contents/{+path}",
"contributors_url": "https://api.github.com/repos/ehuss/triagebot-test/contributors",
"created_at": "2022-06-26T21:31:31Z",
"default_branch": "main",
"deployments_url": "https://api.github.com/repos/ehuss/triagebot-test/deployments",
"description": "Triagebot testing",
"disabled": false,
"downloads_url": "https://api.github.com/repos/ehuss/triagebot-test/downloads",
"events_url": "https://api.github.com/repos/ehuss/triagebot-test/events",
"fork": false,
"forks": 1,
"forks_count": 1,
"forks_url": "https://api.github.com/repos/ehuss/triagebot-test/forks",
"full_name": "ehuss/triagebot-test",
"git_commits_url": "https://api.github.com/repos/ehuss/triagebot-test/git/commits{/sha}",
"git_refs_url": "https://api.github.com/repos/ehuss/triagebot-test/git/refs{/sha}",
"git_tags_url": "https://api.github.com/repos/ehuss/triagebot-test/git/tags{/sha}",
"git_url": "git://github.com/ehuss/triagebot-test.git",
"has_discussions": false,
"has_downloads": true,
"has_issues": true,
"has_pages": false,
"has_projects": true,
"has_wiki": true,
"homepage": null,
"hooks_url": "https://api.github.com/repos/ehuss/triagebot-test/hooks",
"html_url": "https://github.com/ehuss/triagebot-test",
"id": 507688797,
"is_template": false,
"issue_comment_url": "https://api.github.com/repos/ehuss/triagebot-test/issues/comments{/number}",
"issue_events_url": "https://api.github.com/repos/ehuss/triagebot-test/issues/events{/number}",
"issues_url": "https://api.github.com/repos/ehuss/triagebot-test/issues{/number}",
"keys_url": "https://api.github.com/repos/ehuss/triagebot-test/keys{/key_id}",
"labels_url": "https://api.github.com/repos/ehuss/triagebot-test/labels{/name}",
"language": null,
"languages_url": "https://api.github.com/repos/ehuss/triagebot-test/languages",
"license": null,
"merges_url": "https://api.github.com/repos/ehuss/triagebot-test/merges",
"milestones_url": "https://api.github.com/repos/ehuss/triagebot-test/milestones{/number}",
"mirror_url": null,
"name": "triagebot-test",
"node_id": "R_kgDOHkK3XQ",
"notifications_url": "https://api.github.com/repos/ehuss/triagebot-test/notifications{?since,all,participating}",
"open_issues": 7,
"open_issues_count": 7,
"owner": {
"avatar_url": "https://avatars.githubusercontent.com/u/43198?v=4",
"events_url": "https://api.github.com/users/ehuss/events{/privacy}",
"followers_url": "https://api.github.com/users/ehuss/followers",
"following_url": "https://api.github.com/users/ehuss/following{/other_user}",
"gists_url": "https://api.github.com/users/ehuss/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/ehuss",
"id": 43198,
"login": "ehuss",
"node_id": "MDQ6VXNlcjQzMTk4",
"organizations_url": "https://api.github.com/users/ehuss/orgs",
"received_events_url": "https://api.github.com/users/ehuss/received_events",
"repos_url": "https://api.github.com/users/ehuss/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/ehuss/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/ehuss/subscriptions",
"type": "User",
"url": "https://api.github.com/users/ehuss"
},
"private": false,
"pulls_url": "https://api.github.com/repos/ehuss/triagebot-test/pulls{/number}",
"pushed_at": "2023-02-20T19:53:29Z",
"releases_url": "https://api.github.com/repos/ehuss/triagebot-test/releases{/id}",
"size": 18,
"ssh_url": "[email protected]:ehuss/triagebot-test.git",
"stargazers_count": 0,
"stargazers_url": "https://api.github.com/repos/ehuss/triagebot-test/stargazers",
"statuses_url": "https://api.github.com/repos/ehuss/triagebot-test/statuses/{sha}",
"subscribers_url": "https://api.github.com/repos/ehuss/triagebot-test/subscribers",
"subscription_url": "https://api.github.com/repos/ehuss/triagebot-test/subscription",
"svn_url": "https://github.com/ehuss/triagebot-test",
"tags_url": "https://api.github.com/repos/ehuss/triagebot-test/tags",
"teams_url": "https://api.github.com/repos/ehuss/triagebot-test/teams",
"topics": [],
"trees_url": "https://api.github.com/repos/ehuss/triagebot-test/git/trees{/sha}",
"updated_at": "2022-06-26T21:31:31Z",
"url": "https://api.github.com/repos/ehuss/triagebot-test",
"visibility": "public",
"watchers": 0,
"watchers_count": 0,
"web_commit_signoff_required": false
},
"sender": {
"avatar_url": "https://avatars.githubusercontent.com/u/43198?v=4",
"events_url": "https://api.github.com/users/ehuss/events{/privacy}",
"followers_url": "https://api.github.com/users/ehuss/followers",
"following_url": "https://api.github.com/users/ehuss/following{/other_user}",
"gists_url": "https://api.github.com/users/ehuss/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/ehuss",
"id": 43198,
"login": "ehuss",
"node_id": "MDQ6VXNlcjQzMTk4",
"organizations_url": "https://api.github.com/users/ehuss/orgs",
"received_events_url": "https://api.github.com/users/ehuss/received_events",
"repos_url": "https://api.github.com/users/ehuss/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/ehuss/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/ehuss/subscriptions",
"type": "User",
"url": "https://api.github.com/users/ehuss"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"kind": "Request",
"method": "GET",
"path": "/v1/teams.json",
"query": null,
"request_body": "",
"response_code": 200,
"response_body": null
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"kind": "Request",
"method": "GET",
"path": "/v1/teams.json",
"query": null,
"request_body": "",
"response_code": 200,
"response_body": null
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"kind": "Request",
"method": "GET",
"path": "/v1/teams.json",
"query": null,
"request_body": "",
"response_code": 200,
"response_body": null
}
Loading

0 comments on commit 68e214c

Please sign in to comment.