forgejo-hooks: add test for Issue without assignees
Signed-off-by: pep <pep@bouah.net>
This commit is contained in:
parent
f6b031eb1f
commit
f50a6dab52
4 changed files with 193 additions and 4 deletions
|
@ -234,8 +234,8 @@ pub struct IssueAttrs {
|
||||||
pub assets: Vec<String>,
|
pub assets: Vec<String>,
|
||||||
pub labels: Option<Vec<String>>,
|
pub labels: Option<Vec<String>>,
|
||||||
pub milestone: Option<String>,
|
pub milestone: Option<String>,
|
||||||
pub assignee: User,
|
pub assignee: Option<User>,
|
||||||
pub assignees: Vec<User>,
|
pub assignees: Option<Vec<User>>,
|
||||||
pub state: IssueState,
|
pub state: IssueState,
|
||||||
pub is_locked: bool,
|
pub is_locked: bool,
|
||||||
pub comments: u32,
|
pub comments: u32,
|
||||||
|
|
183
forgejo-hooks/src/tests/issue-new.json
Normal file
183
forgejo-hooks/src/tests/issue-new.json
Normal file
|
@ -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": ""
|
||||||
|
}
|
|
@ -54,7 +54,13 @@ fn push_payload() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn issue_opened_payload() {
|
fn issue_new() {
|
||||||
let payload = std::fs::read_to_string("src/tests/issue.json").unwrap();
|
let payload = std::fs::read_to_string("src/tests/issue-new.json").unwrap();
|
||||||
|
let _ = parse_roundtrip::<Issue>(&payload);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn issue_with_assignee() {
|
||||||
|
let payload = std::fs::read_to_string("src/tests/issue-with-assignee.json").unwrap();
|
||||||
let _ = parse_roundtrip::<Issue>(&payload);
|
let _ = parse_roundtrip::<Issue>(&payload);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue