diff --git a/forgejo-hooks/src/lib.rs b/forgejo-hooks/src/lib.rs index 61bd0e7..e856adb 100644 --- a/forgejo-hooks/src/lib.rs +++ b/forgejo-hooks/src/lib.rs @@ -234,8 +234,8 @@ pub struct IssueAttrs { pub assets: Vec, pub labels: Option>, pub milestone: Option, - pub assignee: User, - pub assignees: Vec, + pub assignee: Option, + pub assignees: Option>, pub state: IssueState, pub is_locked: bool, pub comments: u32, diff --git a/forgejo-hooks/src/tests/issue-new.json b/forgejo-hooks/src/tests/issue-new.json new file mode 100644 index 0000000..0226002 --- /dev/null +++ b/forgejo-hooks/src/tests/issue-new.json @@ -0,0 +1,183 @@ +{ + "action": "opened", + "number": 9, + "issue": { + "id": 12, + "url": "https://code.bouah.net/api/v1/repos/pep/webhook-test/issues/9", + "html_url": "https://code.bouah.net/pep/webhook-test/issues/9", + "number": 9, + "user": { + "id": 1, + "login": "pep", + "login_name": "", + "source_id": 0, + "full_name": "", + "email": "pep@bouah.net", + "avatar_url": "https://code.bouah.net/avatars/7897535c1d4a7ed71eb7b9bc8773bed6", + "html_url": "https://code.bouah.net/pep", + "language": "en-US", + "is_admin": true, + "last_login": "2024-09-04T19:40:50Z", + "created": "2023-01-02T21:57:48Z", + "restricted": false, + "active": true, + "prohibit_login": false, + "location": "", + "pronouns": "", + "website": "https://bouah.net", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "pep" + }, + "original_author": "", + "original_author_id": 0, + "title": "If voting changed,", + "body": "They'd make it illegal.", + "ref": "", + "assets": [], + "labels": [], + "milestone": null, + "assignee": null, + "assignees": null, + "state": "open", + "is_locked": false, + "comments": 0, + "created_at": "2024-09-04T19:57:20Z", + "updated_at": "2024-09-04T19:57:20Z", + "closed_at": null, + "due_date": null, + "pull_request": null, + "repository": { + "id": 20, + "name": "webhook-test", + "owner": "pep", + "full_name": "pep/webhook-test" + }, + "pin_order": 0 + }, + "repository": { + "id": 20, + "owner": { + "id": 1, + "login": "pep", + "login_name": "", + "source_id": 0, + "full_name": "", + "email": "pep@bouah.net", + "avatar_url": "https://code.bouah.net/avatars/7897535c1d4a7ed71eb7b9bc8773bed6", + "html_url": "https://code.bouah.net/pep", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2023-01-02T21:57:48Z", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "pronouns": "", + "website": "https://bouah.net", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "pep" + }, + "name": "webhook-test", + "full_name": "pep/webhook-test", + "description": "", + "empty": false, + "private": false, + "fork": false, + "template": false, + "parent": null, + "mirror": false, + "size": 33, + "language": "", + "languages_url": "https://code.bouah.net/api/v1/repos/pep/webhook-test/languages", + "html_url": "https://code.bouah.net/pep/webhook-test", + "url": "https://code.bouah.net/api/v1/repos/pep/webhook-test", + "link": "", + "ssh_url": "forgejo@code.bouah.net:pep/webhook-test.git", + "clone_url": "https://code.bouah.net/pep/webhook-test.git", + "original_url": "", + "website": "", + "stars_count": 0, + "forks_count": 0, + "watchers_count": 1, + "open_issues_count": 8, + "open_pr_counter": 0, + "release_counter": 0, + "default_branch": "main", + "archived": false, + "created_at": "2024-04-23T11:49:34Z", + "updated_at": "2024-09-01T22:47:17Z", + "archived_at": "1970-01-01T00:00:00Z", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "has_issues": true, + "internal_tracker": { + "enable_time_tracker": false, + "allow_only_contributors_to_track_time": true, + "enable_issue_dependencies": true + }, + "has_wiki": true, + "wiki_branch": "master", + "globally_editable_wiki": false, + "has_pull_requests": true, + "has_projects": true, + "has_releases": true, + "has_packages": true, + "has_actions": false, + "ignore_whitespace_conflicts": false, + "allow_merge_commits": true, + "allow_rebase": true, + "allow_rebase_explicit": true, + "allow_squash_merge": true, + "allow_fast_forward_only_merge": false, + "allow_rebase_update": true, + "default_delete_branch_after_merge": false, + "default_merge_style": "rebase", + "default_allow_maintainer_edit": false, + "avatar_url": "", + "internal": false, + "mirror_interval": "", + "object_format_name": "sha1", + "mirror_updated": "0001-01-01T00:00:00Z", + "repo_transfer": null, + "topics": null + }, + "sender": { + "id": 1, + "login": "pep", + "login_name": "", + "source_id": 0, + "full_name": "", + "email": "pep@forgejo-noreply", + "avatar_url": "https://code.bouah.net/avatars/7897535c1d4a7ed71eb7b9bc8773bed6", + "html_url": "https://code.bouah.net/pep", + "language": "", + "is_admin": false, + "last_login": "0001-01-01T00:00:00Z", + "created": "2023-01-02T21:57:48Z", + "restricted": false, + "active": false, + "prohibit_login": false, + "location": "", + "pronouns": "", + "website": "https://bouah.net", + "description": "", + "visibility": "public", + "followers_count": 0, + "following_count": 0, + "starred_repos_count": 0, + "username": "pep" + }, + "commit_id": "" +} diff --git a/forgejo-hooks/src/tests/issue.json b/forgejo-hooks/src/tests/issue-with-assignee.json similarity index 100% rename from forgejo-hooks/src/tests/issue.json rename to forgejo-hooks/src/tests/issue-with-assignee.json diff --git a/forgejo-hooks/src/tests/mod.rs b/forgejo-hooks/src/tests/mod.rs index cb22c39..fc7c808 100644 --- a/forgejo-hooks/src/tests/mod.rs +++ b/forgejo-hooks/src/tests/mod.rs @@ -54,7 +54,13 @@ fn push_payload() { } #[test] -fn issue_opened_payload() { - let payload = std::fs::read_to_string("src/tests/issue.json").unwrap(); +fn issue_new() { + let payload = std::fs::read_to_string("src/tests/issue-new.json").unwrap(); + let _ = parse_roundtrip::(&payload); +} + +#[test] +fn issue_with_assignee() { + let payload = std::fs::read_to_string("src/tests/issue-with-assignee.json").unwrap(); let _ = parse_roundtrip::(&payload); }