mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-28 12:16:17 +01:00
Add some api integration tests (#18872)
depends on #18871 Added some api integration tests to help testing of #18798. Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
This commit is contained in:
parent
18622a0705
commit
a577214760
17 changed files with 2225 additions and 289 deletions
|
@ -3,9 +3,12 @@
|
||||||
uuid: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11
|
uuid: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11
|
||||||
repo_id: 1
|
repo_id: 1
|
||||||
issue_id: 1
|
issue_id: 1
|
||||||
|
release_id: 0
|
||||||
|
uploader_id: 0
|
||||||
comment_id: 0
|
comment_id: 0
|
||||||
name: attach1
|
name: attach1
|
||||||
download_count: 0
|
download_count: 0
|
||||||
|
size: 0
|
||||||
created_unix: 946684800
|
created_unix: 946684800
|
||||||
|
|
||||||
-
|
-
|
||||||
|
@ -13,9 +16,12 @@
|
||||||
uuid: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a12
|
uuid: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a12
|
||||||
repo_id: 2
|
repo_id: 2
|
||||||
issue_id: 4
|
issue_id: 4
|
||||||
|
release_id: 0
|
||||||
|
uploader_id: 0
|
||||||
comment_id: 0
|
comment_id: 0
|
||||||
name: attach2
|
name: attach2
|
||||||
download_count: 1
|
download_count: 1
|
||||||
|
size: 0
|
||||||
created_unix: 946684800
|
created_unix: 946684800
|
||||||
|
|
||||||
-
|
-
|
||||||
|
@ -23,9 +29,12 @@
|
||||||
uuid: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a13
|
uuid: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a13
|
||||||
repo_id: 1
|
repo_id: 1
|
||||||
issue_id: 2
|
issue_id: 2
|
||||||
|
release_id: 0
|
||||||
|
uploader_id: 0
|
||||||
comment_id: 1
|
comment_id: 1
|
||||||
name: attach1
|
name: attach1
|
||||||
download_count: 0
|
download_count: 0
|
||||||
|
size: 0
|
||||||
created_unix: 946684800
|
created_unix: 946684800
|
||||||
|
|
||||||
-
|
-
|
||||||
|
@ -33,9 +42,12 @@
|
||||||
uuid: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a14
|
uuid: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a14
|
||||||
repo_id: 1
|
repo_id: 1
|
||||||
issue_id: 3
|
issue_id: 3
|
||||||
|
release_id: 0
|
||||||
|
uploader_id: 0
|
||||||
comment_id: 1
|
comment_id: 1
|
||||||
name: attach2
|
name: attach2
|
||||||
download_count: 1
|
download_count: 1
|
||||||
|
size: 0
|
||||||
created_unix: 946684800
|
created_unix: 946684800
|
||||||
|
|
||||||
-
|
-
|
||||||
|
@ -43,9 +55,12 @@
|
||||||
uuid: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a15
|
uuid: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a15
|
||||||
repo_id: 2
|
repo_id: 2
|
||||||
issue_id: 4
|
issue_id: 4
|
||||||
|
release_id: 0
|
||||||
|
uploader_id: 0
|
||||||
comment_id: 0
|
comment_id: 0
|
||||||
name: attach1
|
name: attach1
|
||||||
download_count: 0
|
download_count: 0
|
||||||
|
size: 0
|
||||||
created_unix: 946684800
|
created_unix: 946684800
|
||||||
|
|
||||||
-
|
-
|
||||||
|
@ -53,9 +68,12 @@
|
||||||
uuid: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a16
|
uuid: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a16
|
||||||
repo_id: 1
|
repo_id: 1
|
||||||
issue_id: 5
|
issue_id: 5
|
||||||
|
release_id: 0
|
||||||
|
uploader_id: 0
|
||||||
comment_id: 2
|
comment_id: 2
|
||||||
name: attach1
|
name: attach1
|
||||||
download_count: 0
|
download_count: 0
|
||||||
|
size: 0
|
||||||
created_unix: 946684800
|
created_unix: 946684800
|
||||||
|
|
||||||
-
|
-
|
||||||
|
@ -63,9 +81,12 @@
|
||||||
uuid: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a17
|
uuid: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a17
|
||||||
repo_id: 1
|
repo_id: 1
|
||||||
issue_id: 5
|
issue_id: 5
|
||||||
|
release_id: 0
|
||||||
|
uploader_id: 0
|
||||||
comment_id: 2
|
comment_id: 2
|
||||||
name: attach1
|
name: attach1
|
||||||
download_count: 0
|
download_count: 0
|
||||||
|
size: 0
|
||||||
created_unix: 946684800
|
created_unix: 946684800
|
||||||
|
|
||||||
-
|
-
|
||||||
|
@ -73,34 +94,49 @@
|
||||||
uuid: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a18
|
uuid: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a18
|
||||||
repo_id: 3
|
repo_id: 3
|
||||||
issue_id: 6
|
issue_id: 6
|
||||||
|
release_id: 0
|
||||||
|
uploader_id: 0
|
||||||
comment_id: 0
|
comment_id: 0
|
||||||
name: attach1
|
name: attach1
|
||||||
download_count: 0
|
download_count: 0
|
||||||
|
size: 0
|
||||||
created_unix: 946684800
|
created_unix: 946684800
|
||||||
|
|
||||||
-
|
-
|
||||||
id: 9
|
id: 9
|
||||||
uuid: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a19
|
uuid: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a19
|
||||||
repo_id: 1
|
repo_id: 1
|
||||||
|
issue_id: 0
|
||||||
release_id: 1
|
release_id: 1
|
||||||
|
uploader_id: 0
|
||||||
|
comment_id: 0
|
||||||
name: attach1
|
name: attach1
|
||||||
download_count: 0
|
download_count: 0
|
||||||
|
size: 0
|
||||||
created_unix: 946684800
|
created_unix: 946684800
|
||||||
|
|
||||||
-
|
-
|
||||||
id: 10
|
id: 10
|
||||||
uuid: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a20
|
uuid: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a20
|
||||||
repo_id: 0 # TestGetAttachment/NotLinked
|
repo_id: 0 # TestGetAttachment/NotLinked
|
||||||
|
issue_id: 0
|
||||||
|
release_id: 0
|
||||||
uploader_id: 8
|
uploader_id: 8
|
||||||
|
comment_id: 0
|
||||||
name: attach1
|
name: attach1
|
||||||
download_count: 0
|
download_count: 0
|
||||||
|
size: 0
|
||||||
created_unix: 946684800
|
created_unix: 946684800
|
||||||
|
|
||||||
-
|
-
|
||||||
id: 11
|
id: 11
|
||||||
uuid: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a21
|
uuid: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a21
|
||||||
repo_id: 40
|
repo_id: 40
|
||||||
|
issue_id: 0
|
||||||
release_id: 2
|
release_id: 2
|
||||||
|
uploader_id: 0
|
||||||
|
comment_id: 0
|
||||||
name: attach1
|
name: attach1
|
||||||
download_count: 0
|
download_count: 0
|
||||||
|
size: 0
|
||||||
created_unix: 946684800
|
created_unix: 946684800
|
||||||
|
|
|
@ -3,208 +3,287 @@
|
||||||
repo_id: 1
|
repo_id: 1
|
||||||
index: 1
|
index: 1
|
||||||
poster_id: 1
|
poster_id: 1
|
||||||
|
original_author_id: 0
|
||||||
name: issue1
|
name: issue1
|
||||||
content: content for the first issue
|
content: content for the first issue
|
||||||
|
milestone_id: 0
|
||||||
|
priority: 0
|
||||||
is_closed: false
|
is_closed: false
|
||||||
is_pull: false
|
is_pull: false
|
||||||
num_comments: 2
|
num_comments: 2
|
||||||
created_unix: 946684800
|
created_unix: 946684800
|
||||||
updated_unix: 978307200
|
updated_unix: 978307200
|
||||||
|
is_locked: false
|
||||||
|
|
||||||
-
|
-
|
||||||
id: 2
|
id: 2
|
||||||
repo_id: 1
|
repo_id: 1
|
||||||
index: 2
|
index: 2
|
||||||
poster_id: 1
|
poster_id: 1
|
||||||
|
original_author_id: 0
|
||||||
name: issue2
|
name: issue2
|
||||||
content: content for the second issue
|
content: content for the second issue
|
||||||
milestone_id: 1
|
milestone_id: 1
|
||||||
|
priority: 0
|
||||||
is_closed: false
|
is_closed: false
|
||||||
is_pull: true
|
is_pull: true
|
||||||
|
num_comments: 0
|
||||||
created_unix: 946684810
|
created_unix: 946684810
|
||||||
updated_unix: 978307190
|
updated_unix: 978307190
|
||||||
|
is_locked: false
|
||||||
|
|
||||||
-
|
-
|
||||||
id: 3
|
id: 3
|
||||||
repo_id: 1
|
repo_id: 1
|
||||||
index: 3
|
index: 3
|
||||||
poster_id: 1
|
poster_id: 1
|
||||||
|
original_author_id: 0
|
||||||
name: issue3
|
name: issue3
|
||||||
content: content for the third issue
|
content: content for the third issue
|
||||||
milestone_id: 3
|
milestone_id: 3
|
||||||
|
priority: 0
|
||||||
is_closed: false
|
is_closed: false
|
||||||
is_pull: true
|
is_pull: true
|
||||||
|
num_comments: 0
|
||||||
created_unix: 946684820
|
created_unix: 946684820
|
||||||
updated_unix: 978307180
|
updated_unix: 978307180
|
||||||
|
is_locked: false
|
||||||
|
|
||||||
-
|
-
|
||||||
id: 4
|
id: 4
|
||||||
repo_id: 2
|
repo_id: 2
|
||||||
index: 1
|
index: 1
|
||||||
poster_id: 2
|
poster_id: 2
|
||||||
|
original_author_id: 0
|
||||||
name: issue4
|
name: issue4
|
||||||
content: content for the fourth issue
|
content: content for the fourth issue
|
||||||
|
milestone_id: 0
|
||||||
|
priority: 0
|
||||||
is_closed: true
|
is_closed: true
|
||||||
is_pull: false
|
is_pull: false
|
||||||
|
num_comments: 0
|
||||||
created_unix: 946684830
|
created_unix: 946684830
|
||||||
updated_unix: 978307200
|
updated_unix: 978307200
|
||||||
|
is_locked: false
|
||||||
|
|
||||||
-
|
-
|
||||||
id: 5
|
id: 5
|
||||||
repo_id: 1
|
repo_id: 1
|
||||||
index: 4
|
index: 4
|
||||||
poster_id: 2
|
poster_id: 2
|
||||||
|
original_author_id: 0
|
||||||
name: issue5
|
name: issue5
|
||||||
content: content for the fifth issue
|
content: content for the fifth issue
|
||||||
|
milestone_id: 0
|
||||||
|
priority: 0
|
||||||
is_closed: true
|
is_closed: true
|
||||||
is_pull: false
|
is_pull: false
|
||||||
|
num_comments: 0
|
||||||
created_unix: 946684840
|
created_unix: 946684840
|
||||||
updated_unix: 978307200
|
updated_unix: 978307200
|
||||||
|
is_locked: false
|
||||||
|
|
||||||
-
|
-
|
||||||
id: 6
|
id: 6
|
||||||
repo_id: 3
|
repo_id: 3
|
||||||
index: 1
|
index: 1
|
||||||
poster_id: 1
|
poster_id: 1
|
||||||
|
original_author_id: 0
|
||||||
name: issue6
|
name: issue6
|
||||||
content: content6
|
content: content6
|
||||||
|
milestone_id: 0
|
||||||
|
priority: 0
|
||||||
is_closed: false
|
is_closed: false
|
||||||
is_pull: false
|
is_pull: false
|
||||||
num_comments: 0
|
num_comments: 0
|
||||||
created_unix: 946684850
|
created_unix: 946684850
|
||||||
updated_unix: 978307200
|
updated_unix: 978307200
|
||||||
|
is_locked: false
|
||||||
|
|
||||||
-
|
-
|
||||||
id: 7
|
id: 7
|
||||||
repo_id: 2
|
repo_id: 2
|
||||||
index: 2
|
index: 2
|
||||||
poster_id: 2
|
poster_id: 2
|
||||||
|
original_author_id: 0
|
||||||
name: issue7
|
name: issue7
|
||||||
content: content for the seventh issue
|
content: content for the seventh issue
|
||||||
|
milestone_id: 0
|
||||||
|
priority: 0
|
||||||
is_closed: false
|
is_closed: false
|
||||||
is_pull: false
|
is_pull: false
|
||||||
|
num_comments: 0
|
||||||
created_unix: 946684830
|
created_unix: 946684830
|
||||||
updated_unix: 978307200
|
updated_unix: 978307200
|
||||||
|
is_locked: false
|
||||||
|
|
||||||
-
|
-
|
||||||
id: 8
|
id: 8
|
||||||
repo_id: 10
|
repo_id: 10
|
||||||
index: 1
|
index: 1
|
||||||
poster_id: 11
|
poster_id: 11
|
||||||
|
original_author_id: 0
|
||||||
name: pr2
|
name: pr2
|
||||||
content: a pull request
|
content: a pull request
|
||||||
|
milestone_id: 0
|
||||||
|
priority: 0
|
||||||
is_closed: false
|
is_closed: false
|
||||||
is_pull: true
|
is_pull: true
|
||||||
|
num_comments: 0
|
||||||
created_unix: 946684820
|
created_unix: 946684820
|
||||||
updated_unix: 978307180
|
updated_unix: 978307180
|
||||||
|
is_locked: false
|
||||||
|
|
||||||
-
|
-
|
||||||
id: 9
|
id: 9
|
||||||
repo_id: 48
|
repo_id: 48
|
||||||
index: 1
|
index: 1
|
||||||
poster_id: 11
|
poster_id: 11
|
||||||
|
original_author_id: 0
|
||||||
name: pr1
|
name: pr1
|
||||||
content: a pull request
|
content: a pull request
|
||||||
|
milestone_id: 0
|
||||||
|
priority: 0
|
||||||
is_closed: false
|
is_closed: false
|
||||||
is_pull: true
|
is_pull: true
|
||||||
|
num_comments: 0
|
||||||
created_unix: 946684820
|
created_unix: 946684820
|
||||||
updated_unix: 978307180
|
updated_unix: 978307180
|
||||||
|
is_locked: false
|
||||||
|
|
||||||
-
|
-
|
||||||
id: 10
|
id: 10
|
||||||
repo_id: 42
|
repo_id: 42
|
||||||
index: 1
|
index: 1
|
||||||
poster_id: 500
|
poster_id: 500
|
||||||
|
original_author_id: 0
|
||||||
name: issue from deleted account
|
name: issue from deleted account
|
||||||
content: content from deleted account
|
content: content from deleted account
|
||||||
|
milestone_id: 0
|
||||||
|
priority: 0
|
||||||
is_closed: false
|
is_closed: false
|
||||||
is_pull: false
|
is_pull: false
|
||||||
|
num_comments: 0
|
||||||
|
deadline_unix: 1019307200
|
||||||
created_unix: 946684830
|
created_unix: 946684830
|
||||||
updated_unix: 999307200
|
updated_unix: 999307200
|
||||||
deadline_unix: 1019307200
|
is_locked: false
|
||||||
|
|
||||||
-
|
-
|
||||||
id: 11
|
id: 11
|
||||||
repo_id: 1
|
repo_id: 1
|
||||||
index: 5
|
index: 5
|
||||||
poster_id: 1
|
poster_id: 1
|
||||||
|
original_author_id: 0
|
||||||
name: pull5
|
name: pull5
|
||||||
content: content for the a pull request
|
content: content for the a pull request
|
||||||
|
milestone_id: 0
|
||||||
|
priority: 0
|
||||||
is_closed: false
|
is_closed: false
|
||||||
is_pull: true
|
is_pull: true
|
||||||
|
num_comments: 0
|
||||||
created_unix: 1579194806
|
created_unix: 1579194806
|
||||||
updated_unix: 1579194806
|
updated_unix: 1579194806
|
||||||
|
is_locked: false
|
||||||
|
|
||||||
-
|
-
|
||||||
id: 12
|
id: 12
|
||||||
repo_id: 3
|
repo_id: 3
|
||||||
index: 2
|
index: 2
|
||||||
poster_id: 2
|
poster_id: 2
|
||||||
|
original_author_id: 0
|
||||||
name: pull6
|
name: pull6
|
||||||
content: content for the a pull request
|
content: content for the a pull request
|
||||||
|
milestone_id: 0
|
||||||
|
priority: 0
|
||||||
is_closed: false
|
is_closed: false
|
||||||
is_pull: true
|
is_pull: true
|
||||||
|
num_comments: 0
|
||||||
created_unix: 1602935696
|
created_unix: 1602935696
|
||||||
updated_unix: 1602935696
|
updated_unix: 1602935696
|
||||||
|
is_locked: false
|
||||||
|
|
||||||
-
|
-
|
||||||
id: 13
|
id: 13
|
||||||
repo_id: 50
|
repo_id: 50
|
||||||
index: 1
|
index: 1
|
||||||
poster_id: 2
|
poster_id: 2
|
||||||
|
original_author_id: 0
|
||||||
name: issue in active repo
|
name: issue in active repo
|
||||||
content: we'll be testing github issue 13171 with this.
|
content: we'll be testing github issue 13171 with this.
|
||||||
|
milestone_id: 0
|
||||||
|
priority: 0
|
||||||
is_closed: false
|
is_closed: false
|
||||||
is_pull: false
|
is_pull: false
|
||||||
|
num_comments: 0
|
||||||
created_unix: 1602935696
|
created_unix: 1602935696
|
||||||
updated_unix: 1602935696
|
updated_unix: 1602935696
|
||||||
|
is_locked: false
|
||||||
|
|
||||||
-
|
-
|
||||||
id: 14
|
id: 14
|
||||||
repo_id: 51
|
repo_id: 51
|
||||||
index: 1
|
index: 1
|
||||||
poster_id: 2
|
poster_id: 2
|
||||||
|
original_author_id: 0
|
||||||
name: issue in archived repo
|
name: issue in archived repo
|
||||||
content: we'll be testing github issue 13171 with this.
|
content: we'll be testing github issue 13171 with this.
|
||||||
|
milestone_id: 0
|
||||||
|
priority: 0
|
||||||
is_closed: false
|
is_closed: false
|
||||||
is_pull: false
|
is_pull: false
|
||||||
|
num_comments: 0
|
||||||
created_unix: 1602935696
|
created_unix: 1602935696
|
||||||
updated_unix: 1602935696
|
updated_unix: 1602935696
|
||||||
|
is_locked: false
|
||||||
|
|
||||||
-
|
-
|
||||||
id: 15
|
id: 15
|
||||||
repo_id: 5
|
repo_id: 5
|
||||||
index: 1
|
index: 1
|
||||||
poster_id: 2
|
poster_id: 2
|
||||||
|
original_author_id: 0
|
||||||
name: issue in repo not linked to team1
|
name: issue in repo not linked to team1
|
||||||
content: content
|
content: content
|
||||||
|
milestone_id: 0
|
||||||
|
priority: 0
|
||||||
is_closed: false
|
is_closed: false
|
||||||
is_pull: false
|
is_pull: false
|
||||||
|
num_comments: 0
|
||||||
created_unix: 1602935696
|
created_unix: 1602935696
|
||||||
updated_unix: 1602935696
|
updated_unix: 1602935696
|
||||||
|
is_locked: false
|
||||||
|
|
||||||
-
|
-
|
||||||
id: 16
|
id: 16
|
||||||
repo_id: 32
|
repo_id: 32
|
||||||
index: 1
|
index: 1
|
||||||
poster_id: 2
|
poster_id: 2
|
||||||
|
original_author_id: 0
|
||||||
name: just a normal issue
|
name: just a normal issue
|
||||||
content: content
|
content: content
|
||||||
|
milestone_id: 0
|
||||||
|
priority: 0
|
||||||
is_closed: false
|
is_closed: false
|
||||||
is_pull: false
|
is_pull: false
|
||||||
|
num_comments: 0
|
||||||
created_unix: 1602935696
|
created_unix: 1602935696
|
||||||
updated_unix: 1602935696
|
updated_unix: 1602935696
|
||||||
|
is_locked: false
|
||||||
|
|
||||||
-
|
-
|
||||||
id: 17
|
id: 17
|
||||||
repo_id: 32
|
repo_id: 32
|
||||||
index: 2
|
index: 2
|
||||||
poster_id: 15
|
poster_id: 15
|
||||||
|
original_author_id: 0
|
||||||
name: a issue with a assignment
|
name: a issue with a assignment
|
||||||
content: content
|
content: content
|
||||||
|
milestone_id: 0
|
||||||
|
priority: 0
|
||||||
is_closed: false
|
is_closed: false
|
||||||
is_pull: false
|
is_pull: false
|
||||||
|
num_comments: 0
|
||||||
created_unix: 1602935696
|
created_unix: 1602935696
|
||||||
updated_unix: 1602935696
|
updated_unix: 1602935696
|
||||||
|
is_locked: false
|
||||||
|
|
|
@ -15,10 +15,11 @@
|
||||||
color: '#000000'
|
color: '#000000'
|
||||||
num_issues: 1
|
num_issues: 1
|
||||||
num_closed_issues: 1
|
num_closed_issues: 1
|
||||||
|
|
||||||
-
|
-
|
||||||
id: 3
|
id: 3
|
||||||
repo_id: 0
|
repo_id: 0
|
||||||
org_id: 3
|
org_id: 3
|
||||||
name: orglabel3
|
name: orglabel3
|
||||||
color: '#abcdef'
|
color: '#abcdef'
|
||||||
num_issues: 0
|
num_issues: 0
|
||||||
|
@ -32,7 +33,7 @@
|
||||||
color: '#000000'
|
color: '#000000'
|
||||||
num_issues: 1
|
num_issues: 1
|
||||||
num_closed_issues: 0
|
num_closed_issues: 0
|
||||||
|
|
||||||
-
|
-
|
||||||
id: 5
|
id: 5
|
||||||
repo_id: 10
|
repo_id: 10
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
is_closed: false
|
is_closed: false
|
||||||
num_issues: 1
|
num_issues: 1
|
||||||
num_closed_issues: 0
|
num_closed_issues: 0
|
||||||
|
completeness: 0
|
||||||
deadline_unix: 253370764800
|
deadline_unix: 253370764800
|
||||||
|
|
||||||
-
|
-
|
||||||
|
@ -16,6 +17,7 @@
|
||||||
is_closed: false
|
is_closed: false
|
||||||
num_issues: 0
|
num_issues: 0
|
||||||
num_closed_issues: 0
|
num_closed_issues: 0
|
||||||
|
completeness: 0
|
||||||
deadline_unix: 253370764800
|
deadline_unix: 253370764800
|
||||||
|
|
||||||
-
|
-
|
||||||
|
@ -26,6 +28,7 @@
|
||||||
is_closed: true
|
is_closed: true
|
||||||
num_issues: 1
|
num_issues: 1
|
||||||
num_closed_issues: 0
|
num_closed_issues: 0
|
||||||
|
completeness: 0
|
||||||
deadline_unix: 253370764800
|
deadline_unix: 253370764800
|
||||||
|
|
||||||
-
|
-
|
||||||
|
@ -36,14 +39,16 @@
|
||||||
is_closed: false
|
is_closed: false
|
||||||
num_issues: 0
|
num_issues: 0
|
||||||
num_closed_issues: 0
|
num_closed_issues: 0
|
||||||
|
completeness: 0
|
||||||
deadline_unix: 253370764800
|
deadline_unix: 253370764800
|
||||||
|
|
||||||
-
|
-
|
||||||
id: 5
|
id: 5
|
||||||
repo_id: 10
|
repo_id: 10
|
||||||
name: milestone of repo 10
|
name: milestone of repo 10
|
||||||
content: for testing with PRs
|
content: for testing with PRs
|
||||||
is_closed: false
|
is_closed: false
|
||||||
num_issues: 0
|
num_issues: 0
|
||||||
num_closed_issues: 0
|
num_closed_issues: 0
|
||||||
|
completeness: 0
|
||||||
deadline_unix: 253370764800
|
deadline_unix: 253370764800
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -6,6 +6,7 @@
|
||||||
authorize: 4 # owner
|
authorize: 4 # owner
|
||||||
num_repos: 3
|
num_repos: 3
|
||||||
num_members: 1
|
num_members: 1
|
||||||
|
includes_all_repositories: false
|
||||||
can_create_org_repo: true
|
can_create_org_repo: true
|
||||||
|
|
||||||
-
|
-
|
||||||
|
@ -16,6 +17,7 @@
|
||||||
authorize: 2 # write
|
authorize: 2 # write
|
||||||
num_repos: 1
|
num_repos: 1
|
||||||
num_members: 2
|
num_members: 2
|
||||||
|
includes_all_repositories: false
|
||||||
can_create_org_repo: false
|
can_create_org_repo: false
|
||||||
|
|
||||||
-
|
-
|
||||||
|
@ -26,6 +28,7 @@
|
||||||
authorize: 4 # owner
|
authorize: 4 # owner
|
||||||
num_repos: 0
|
num_repos: 0
|
||||||
num_members: 1
|
num_members: 1
|
||||||
|
includes_all_repositories: false
|
||||||
can_create_org_repo: true
|
can_create_org_repo: true
|
||||||
|
|
||||||
-
|
-
|
||||||
|
@ -36,6 +39,7 @@
|
||||||
authorize: 4 # owner
|
authorize: 4 # owner
|
||||||
num_repos: 0
|
num_repos: 0
|
||||||
num_members: 1
|
num_members: 1
|
||||||
|
includes_all_repositories: false
|
||||||
can_create_org_repo: true
|
can_create_org_repo: true
|
||||||
|
|
||||||
-
|
-
|
||||||
|
@ -46,6 +50,7 @@
|
||||||
authorize: 4 # owner
|
authorize: 4 # owner
|
||||||
num_repos: 2
|
num_repos: 2
|
||||||
num_members: 2
|
num_members: 2
|
||||||
|
includes_all_repositories: false
|
||||||
can_create_org_repo: true
|
can_create_org_repo: true
|
||||||
|
|
||||||
-
|
-
|
||||||
|
@ -56,6 +61,7 @@
|
||||||
authorize: 4 # owner
|
authorize: 4 # owner
|
||||||
num_repos: 2
|
num_repos: 2
|
||||||
num_members: 2
|
num_members: 2
|
||||||
|
includes_all_repositories: false
|
||||||
can_create_org_repo: true
|
can_create_org_repo: true
|
||||||
|
|
||||||
-
|
-
|
||||||
|
@ -66,6 +72,7 @@
|
||||||
authorize: 2 # write
|
authorize: 2 # write
|
||||||
num_repos: 1
|
num_repos: 1
|
||||||
num_members: 1
|
num_members: 1
|
||||||
|
includes_all_repositories: false
|
||||||
can_create_org_repo: false
|
can_create_org_repo: false
|
||||||
|
|
||||||
-
|
-
|
||||||
|
@ -76,6 +83,7 @@
|
||||||
authorize: 2 # write
|
authorize: 2 # write
|
||||||
num_repos: 1
|
num_repos: 1
|
||||||
num_members: 1
|
num_members: 1
|
||||||
|
includes_all_repositories: false
|
||||||
can_create_org_repo: false
|
can_create_org_repo: false
|
||||||
|
|
||||||
-
|
-
|
||||||
|
@ -86,6 +94,7 @@
|
||||||
authorize: 1 # read
|
authorize: 1 # read
|
||||||
num_repos: 1
|
num_repos: 1
|
||||||
num_members: 2
|
num_members: 2
|
||||||
|
includes_all_repositories: false
|
||||||
can_create_org_repo: false
|
can_create_org_repo: false
|
||||||
|
|
||||||
-
|
-
|
||||||
|
@ -93,9 +102,10 @@
|
||||||
org_id: 25
|
org_id: 25
|
||||||
lower_name: notowners
|
lower_name: notowners
|
||||||
name: NotOwners
|
name: NotOwners
|
||||||
authorize: 1 # owner
|
authorize: 1 # read
|
||||||
num_repos: 0
|
num_repos: 0
|
||||||
num_members: 1
|
num_members: 1
|
||||||
|
includes_all_repositories: false
|
||||||
can_create_org_repo: false
|
can_create_org_repo: false
|
||||||
|
|
||||||
-
|
-
|
||||||
|
@ -106,6 +116,7 @@
|
||||||
authorize: 1 # read
|
authorize: 1 # read
|
||||||
num_repos: 0
|
num_repos: 0
|
||||||
num_members: 0
|
num_members: 0
|
||||||
|
includes_all_repositories: false
|
||||||
can_create_org_repo: false
|
can_create_org_repo: false
|
||||||
|
|
||||||
-
|
-
|
||||||
|
@ -116,6 +127,7 @@
|
||||||
authorize: 3 # admin
|
authorize: 3 # admin
|
||||||
num_repos: 0
|
num_repos: 0
|
||||||
num_members: 1
|
num_members: 1
|
||||||
|
includes_all_repositories: false
|
||||||
can_create_org_repo: true
|
can_create_org_repo: true
|
||||||
|
|
||||||
-
|
-
|
||||||
|
@ -126,4 +138,5 @@
|
||||||
authorize: 3 # admin
|
authorize: 3 # admin
|
||||||
num_repos: 0
|
num_repos: 0
|
||||||
num_members: 1
|
num_members: 1
|
||||||
|
includes_all_repositories: false
|
||||||
can_create_org_repo: false
|
can_create_org_repo: false
|
||||||
|
|
|
@ -8,18 +8,22 @@
|
||||||
name: database
|
name: database
|
||||||
repo_count: 1
|
repo_count: 1
|
||||||
|
|
||||||
- id: 3
|
-
|
||||||
|
id: 3
|
||||||
name: SQL
|
name: SQL
|
||||||
repo_count: 1
|
repo_count: 1
|
||||||
|
|
||||||
- id: 4
|
-
|
||||||
|
id: 4
|
||||||
name: graphql
|
name: graphql
|
||||||
repo_count: 1
|
repo_count: 1
|
||||||
|
|
||||||
- id: 5
|
-
|
||||||
|
id: 5
|
||||||
name: topicname1
|
name: topicname1
|
||||||
repo_count: 1
|
repo_count: 1
|
||||||
|
|
||||||
- id: 6
|
-
|
||||||
|
id: 6
|
||||||
name: topicname2
|
name: topicname2
|
||||||
repo_count: 2
|
repo_count: 2
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,6 @@
|
||||||
- id: 1
|
-
|
||||||
name: "WebAuthn credential"
|
id: 1
|
||||||
|
name: WebAuthn credential
|
||||||
user_id: 32
|
user_id: 32
|
||||||
attestation_type: none
|
attestation_type: none
|
||||||
sign_count: 0
|
sign_count: 0
|
||||||
|
|
|
@ -102,7 +102,7 @@ func TestSearchUsers(t *testing.T) {
|
||||||
[]int64{9})
|
[]int64{9})
|
||||||
|
|
||||||
testUserSuccess(&user_model.SearchUserOptions{OrderBy: "id ASC", ListOptions: db.ListOptions{Page: 1}, IsActive: util.OptionalBoolTrue},
|
testUserSuccess(&user_model.SearchUserOptions{OrderBy: "id ASC", ListOptions: db.ListOptions{Page: 1}, IsActive: util.OptionalBoolTrue},
|
||||||
[]int64{1, 2, 4, 5, 8, 10, 11, 12, 13, 14, 15, 16, 18, 20, 21, 24, 28, 29, 30, 32})
|
[]int64{1, 2, 4, 5, 8, 10, 11, 12, 13, 14, 15, 16, 18, 20, 21, 24, 27, 28, 29, 30, 32})
|
||||||
|
|
||||||
testUserSuccess(&user_model.SearchUserOptions{Keyword: "user1", OrderBy: "id ASC", ListOptions: db.ListOptions{Page: 1}, IsActive: util.OptionalBoolTrue},
|
testUserSuccess(&user_model.SearchUserOptions{Keyword: "user1", OrderBy: "id ASC", ListOptions: db.ListOptions{Page: 1}, IsActive: util.OptionalBoolTrue},
|
||||||
[]int64{1, 10, 11, 12, 13, 14, 15, 16, 18})
|
[]int64{1, 10, 11, 12, 13, 14, 15, 16, 18})
|
||||||
|
|
|
@ -76,7 +76,7 @@ func TestPulls(t *testing.T) {
|
||||||
Pulls(ctx)
|
Pulls(ctx)
|
||||||
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
||||||
|
|
||||||
assert.Len(t, ctx.Data["Issues"], 3)
|
assert.Len(t, ctx.Data["Issues"], 4)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMilestones(t *testing.T) {
|
func TestMilestones(t *testing.T) {
|
||||||
|
|
|
@ -167,6 +167,33 @@ func TestAPICreateUserInvalidEmail(t *testing.T) {
|
||||||
session.MakeRequest(t, req, http.StatusUnprocessableEntity)
|
session.MakeRequest(t, req, http.StatusUnprocessableEntity)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAPICreateAndDeleteUser(t *testing.T) {
|
||||||
|
defer tests.PrepareTestEnv(t)()
|
||||||
|
adminUsername := "user1"
|
||||||
|
session := loginUser(t, adminUsername)
|
||||||
|
token := getTokenForLoggedInUser(t, session)
|
||||||
|
|
||||||
|
req := NewRequestWithValues(
|
||||||
|
t,
|
||||||
|
"POST",
|
||||||
|
fmt.Sprintf("/api/v1/admin/users?token=%s", token),
|
||||||
|
map[string]string{
|
||||||
|
"email": "deleteme@domain.com",
|
||||||
|
"full_name": "delete me",
|
||||||
|
"login_name": "deleteme",
|
||||||
|
"must_change_password": "true",
|
||||||
|
"password": "password",
|
||||||
|
"send_notify": "true",
|
||||||
|
"source_id": "0",
|
||||||
|
"username": "deleteme",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
MakeRequest(t, req, http.StatusCreated)
|
||||||
|
|
||||||
|
req = NewRequest(t, "DELETE", fmt.Sprintf("/api/v1/admin/users/deleteme?token=%s", token))
|
||||||
|
MakeRequest(t, req, http.StatusNoContent)
|
||||||
|
}
|
||||||
|
|
||||||
func TestAPIEditUser(t *testing.T) {
|
func TestAPIEditUser(t *testing.T) {
|
||||||
defer tests.PrepareTestEnv(t)()
|
defer tests.PrepareTestEnv(t)()
|
||||||
adminUsername := "user1"
|
adminUsername := "user1"
|
||||||
|
@ -209,3 +236,20 @@ func TestAPIEditUser(t *testing.T) {
|
||||||
user2 = unittest.AssertExistsAndLoadBean(t, &user_model.User{LoginName: "user2"})
|
user2 = unittest.AssertExistsAndLoadBean(t, &user_model.User{LoginName: "user2"})
|
||||||
assert.True(t, user2.IsRestricted)
|
assert.True(t, user2.IsRestricted)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAPICreateRepoForUser(t *testing.T) {
|
||||||
|
defer tests.PrepareTestEnv(t)()
|
||||||
|
adminUsername := "user1"
|
||||||
|
session := loginUser(t, adminUsername)
|
||||||
|
token := getTokenForLoggedInUser(t, session)
|
||||||
|
|
||||||
|
req := NewRequestWithJSON(
|
||||||
|
t,
|
||||||
|
"POST",
|
||||||
|
fmt.Sprintf("/api/v1/admin/users/%s/repos?token=%s", adminUsername, token),
|
||||||
|
&api.CreateRepoOption{
|
||||||
|
Name: "admincreatedrepo",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
MakeRequest(t, req, http.StatusCreated)
|
||||||
|
}
|
||||||
|
|
38
tests/integration/api_feed_user_test.go
Normal file
38
tests/integration/api_feed_user_test.go
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
// Copyright 2022 The Gitea Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a MIT-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package integration
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"code.gitea.io/gitea/tests"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestFeed(t *testing.T) {
|
||||||
|
t.Run("User", func(t *testing.T) {
|
||||||
|
t.Run("Atom", func(t *testing.T) {
|
||||||
|
defer tests.PrepareTestEnv(t)()
|
||||||
|
|
||||||
|
req := NewRequest(t, "GET", "/user2.atom")
|
||||||
|
resp := MakeRequest(t, req, http.StatusOK)
|
||||||
|
|
||||||
|
data := resp.Body.String()
|
||||||
|
assert.Contains(t, data, `<feed xmlns="http://www.w3.org/2005/Atom"`)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("RSS", func(t *testing.T) {
|
||||||
|
defer tests.PrepareTestEnv(t)()
|
||||||
|
|
||||||
|
req := NewRequest(t, "GET", "/user2.rss")
|
||||||
|
resp := MakeRequest(t, req, http.StatusOK)
|
||||||
|
|
||||||
|
data := resp.Body.String()
|
||||||
|
assert.Contains(t, data, `<rss version="2.0"`)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
111
tests/integration/api_user_follow_test.go
Normal file
111
tests/integration/api_user_follow_test.go
Normal file
|
@ -0,0 +1,111 @@
|
||||||
|
// Copyright 2022 The Gitea Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a MIT-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package integration
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
api "code.gitea.io/gitea/modules/structs"
|
||||||
|
"code.gitea.io/gitea/tests"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestAPIFollow(t *testing.T) {
|
||||||
|
defer tests.PrepareTestEnv(t)()
|
||||||
|
|
||||||
|
user1 := "user4"
|
||||||
|
user2 := "user1"
|
||||||
|
|
||||||
|
session1 := loginUser(t, user1)
|
||||||
|
token1 := getTokenForLoggedInUser(t, session1)
|
||||||
|
|
||||||
|
session2 := loginUser(t, user2)
|
||||||
|
token2 := getTokenForLoggedInUser(t, session2)
|
||||||
|
|
||||||
|
t.Run("Follow", func(t *testing.T) {
|
||||||
|
defer tests.PrintCurrentTest(t)()
|
||||||
|
|
||||||
|
req := NewRequest(t, "PUT", fmt.Sprintf("/api/v1/user/following/%s?token=%s", user1, token2))
|
||||||
|
MakeRequest(t, req, http.StatusNoContent)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("ListFollowing", func(t *testing.T) {
|
||||||
|
defer tests.PrintCurrentTest(t)()
|
||||||
|
|
||||||
|
req := NewRequest(t, "GET", fmt.Sprintf("/api/v1/users/%s/following?token=%s", user2, token2))
|
||||||
|
resp := MakeRequest(t, req, http.StatusOK)
|
||||||
|
|
||||||
|
var users []api.User
|
||||||
|
DecodeJSON(t, resp, &users)
|
||||||
|
assert.Len(t, users, 1)
|
||||||
|
assert.Equal(t, user1, users[0].UserName)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("ListMyFollowing", func(t *testing.T) {
|
||||||
|
defer tests.PrintCurrentTest(t)()
|
||||||
|
|
||||||
|
req := NewRequest(t, "GET", fmt.Sprintf("/api/v1/user/following?token=%s", token2))
|
||||||
|
resp := MakeRequest(t, req, http.StatusOK)
|
||||||
|
|
||||||
|
var users []api.User
|
||||||
|
DecodeJSON(t, resp, &users)
|
||||||
|
assert.Len(t, users, 1)
|
||||||
|
assert.Equal(t, user1, users[0].UserName)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("ListFollowers", func(t *testing.T) {
|
||||||
|
defer tests.PrintCurrentTest(t)()
|
||||||
|
|
||||||
|
req := NewRequest(t, "GET", fmt.Sprintf("/api/v1/users/%s/followers?token=%s", user1, token1))
|
||||||
|
resp := MakeRequest(t, req, http.StatusOK)
|
||||||
|
|
||||||
|
var users []api.User
|
||||||
|
DecodeJSON(t, resp, &users)
|
||||||
|
assert.Len(t, users, 1)
|
||||||
|
assert.Equal(t, user2, users[0].UserName)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("ListMyFollowers", func(t *testing.T) {
|
||||||
|
defer tests.PrintCurrentTest(t)()
|
||||||
|
|
||||||
|
req := NewRequest(t, "GET", fmt.Sprintf("/api/v1/user/followers?token=%s", token1))
|
||||||
|
resp := MakeRequest(t, req, http.StatusOK)
|
||||||
|
|
||||||
|
var users []api.User
|
||||||
|
DecodeJSON(t, resp, &users)
|
||||||
|
assert.Len(t, users, 1)
|
||||||
|
assert.Equal(t, user2, users[0].UserName)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("CheckFollowing", func(t *testing.T) {
|
||||||
|
defer tests.PrintCurrentTest(t)()
|
||||||
|
|
||||||
|
req := NewRequest(t, "GET", fmt.Sprintf("/api/v1/users/%s/following/%s?token=%s", user2, user1, token2))
|
||||||
|
MakeRequest(t, req, http.StatusNoContent)
|
||||||
|
|
||||||
|
req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/users/%s/following/%s?token=%s", user1, user2, token2))
|
||||||
|
MakeRequest(t, req, http.StatusNotFound)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("CheckMyFollowing", func(t *testing.T) {
|
||||||
|
defer tests.PrintCurrentTest(t)()
|
||||||
|
|
||||||
|
req := NewRequest(t, "GET", fmt.Sprintf("/api/v1/user/following/%s?token=%s", user1, token2))
|
||||||
|
MakeRequest(t, req, http.StatusNoContent)
|
||||||
|
|
||||||
|
req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/user/following/%s?token=%s", user2, token1))
|
||||||
|
MakeRequest(t, req, http.StatusNotFound)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("Unfollow", func(t *testing.T) {
|
||||||
|
defer tests.PrintCurrentTest(t)()
|
||||||
|
|
||||||
|
req := NewRequest(t, "DELETE", fmt.Sprintf("/api/v1/user/following/%s?token=%s", user1, token2))
|
||||||
|
MakeRequest(t, req, http.StatusNoContent)
|
||||||
|
})
|
||||||
|
}
|
51
tests/integration/api_user_info_test.go
Normal file
51
tests/integration/api_user_info_test.go
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
// Copyright 2022 The Gitea Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a MIT-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package integration
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
api "code.gitea.io/gitea/modules/structs"
|
||||||
|
"code.gitea.io/gitea/tests"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestAPIUserInfo(t *testing.T) {
|
||||||
|
defer tests.PrepareTestEnv(t)()
|
||||||
|
|
||||||
|
user := "user1"
|
||||||
|
user2 := "user31"
|
||||||
|
|
||||||
|
session := loginUser(t, user)
|
||||||
|
token := getTokenForLoggedInUser(t, session)
|
||||||
|
|
||||||
|
t.Run("GetInfo", func(t *testing.T) {
|
||||||
|
defer tests.PrintCurrentTest(t)()
|
||||||
|
|
||||||
|
req := NewRequest(t, "GET", fmt.Sprintf("/api/v1/users/%s?token=%s", user2, token))
|
||||||
|
resp := MakeRequest(t, req, http.StatusOK)
|
||||||
|
|
||||||
|
var u api.User
|
||||||
|
DecodeJSON(t, resp, &u)
|
||||||
|
assert.Equal(t, user2, u.UserName)
|
||||||
|
|
||||||
|
req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/users/%s", user2))
|
||||||
|
MakeRequest(t, req, http.StatusNotFound)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("GetAuthenticatedUser", func(t *testing.T) {
|
||||||
|
defer tests.PrintCurrentTest(t)()
|
||||||
|
|
||||||
|
req := NewRequest(t, "GET", fmt.Sprintf("/api/v1/user?token=%s", token))
|
||||||
|
resp := MakeRequest(t, req, http.StatusOK)
|
||||||
|
|
||||||
|
var u api.User
|
||||||
|
DecodeJSON(t, resp, &u)
|
||||||
|
assert.Equal(t, user, u.UserName)
|
||||||
|
})
|
||||||
|
}
|
78
tests/integration/api_user_star_test.go
Normal file
78
tests/integration/api_user_star_test.go
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
// Copyright 2022 The Gitea Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a MIT-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package integration
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
api "code.gitea.io/gitea/modules/structs"
|
||||||
|
"code.gitea.io/gitea/tests"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestAPIStar(t *testing.T) {
|
||||||
|
defer tests.PrepareTestEnv(t)()
|
||||||
|
|
||||||
|
user := "user1"
|
||||||
|
repo := "user2/repo1"
|
||||||
|
|
||||||
|
session := loginUser(t, user)
|
||||||
|
token := getTokenForLoggedInUser(t, session)
|
||||||
|
|
||||||
|
t.Run("Star", func(t *testing.T) {
|
||||||
|
defer tests.PrintCurrentTest(t)()
|
||||||
|
|
||||||
|
req := NewRequest(t, "PUT", fmt.Sprintf("/api/v1/user/starred/%s?token=%s", repo, token))
|
||||||
|
MakeRequest(t, req, http.StatusNoContent)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("GetStarredRepos", func(t *testing.T) {
|
||||||
|
defer tests.PrintCurrentTest(t)()
|
||||||
|
|
||||||
|
req := NewRequest(t, "GET", fmt.Sprintf("/api/v1/users/%s/starred?token=%s", user, token))
|
||||||
|
resp := MakeRequest(t, req, http.StatusOK)
|
||||||
|
|
||||||
|
assert.Equal(t, "1", resp.Header().Get("X-Total-Count"))
|
||||||
|
|
||||||
|
var repos []api.Repository
|
||||||
|
DecodeJSON(t, resp, &repos)
|
||||||
|
assert.Len(t, repos, 1)
|
||||||
|
assert.Equal(t, repo, repos[0].FullName)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("GetMyStarredRepos", func(t *testing.T) {
|
||||||
|
defer tests.PrintCurrentTest(t)()
|
||||||
|
|
||||||
|
req := NewRequest(t, "GET", fmt.Sprintf("/api/v1/user/starred?token=%s", token))
|
||||||
|
resp := MakeRequest(t, req, http.StatusOK)
|
||||||
|
|
||||||
|
assert.Equal(t, "1", resp.Header().Get("X-Total-Count"))
|
||||||
|
|
||||||
|
var repos []api.Repository
|
||||||
|
DecodeJSON(t, resp, &repos)
|
||||||
|
assert.Len(t, repos, 1)
|
||||||
|
assert.Equal(t, repo, repos[0].FullName)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("IsStarring", func(t *testing.T) {
|
||||||
|
defer tests.PrintCurrentTest(t)()
|
||||||
|
|
||||||
|
req := NewRequest(t, "GET", fmt.Sprintf("/api/v1/user/starred/%s?token=%s", repo, token))
|
||||||
|
MakeRequest(t, req, http.StatusNoContent)
|
||||||
|
|
||||||
|
req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/user/starred/%s?token=%s", repo+"notexisting", token))
|
||||||
|
MakeRequest(t, req, http.StatusNotFound)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("Unstar", func(t *testing.T) {
|
||||||
|
defer tests.PrintCurrentTest(t)()
|
||||||
|
|
||||||
|
req := NewRequest(t, "DELETE", fmt.Sprintf("/api/v1/user/starred/%s?token=%s", repo, token))
|
||||||
|
MakeRequest(t, req, http.StatusNoContent)
|
||||||
|
})
|
||||||
|
}
|
78
tests/integration/api_user_watch_test.go
Normal file
78
tests/integration/api_user_watch_test.go
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
// Copyright 2022 The Gitea Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a MIT-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package integration
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
api "code.gitea.io/gitea/modules/structs"
|
||||||
|
"code.gitea.io/gitea/tests"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestAPIWatch(t *testing.T) {
|
||||||
|
defer tests.PrepareTestEnv(t)()
|
||||||
|
|
||||||
|
user := "user1"
|
||||||
|
repo := "user2/repo1"
|
||||||
|
|
||||||
|
session := loginUser(t, user)
|
||||||
|
token := getTokenForLoggedInUser(t, session)
|
||||||
|
|
||||||
|
t.Run("Watch", func(t *testing.T) {
|
||||||
|
defer tests.PrintCurrentTest(t)()
|
||||||
|
|
||||||
|
req := NewRequest(t, "PUT", fmt.Sprintf("/api/v1/repos/%s/subscription?token=%s", repo, token))
|
||||||
|
MakeRequest(t, req, http.StatusOK)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("GetWatchedRepos", func(t *testing.T) {
|
||||||
|
defer tests.PrintCurrentTest(t)()
|
||||||
|
|
||||||
|
req := NewRequest(t, "GET", fmt.Sprintf("/api/v1/users/%s/subscriptions?token=%s", user, token))
|
||||||
|
resp := MakeRequest(t, req, http.StatusOK)
|
||||||
|
|
||||||
|
assert.Equal(t, "1", resp.Header().Get("X-Total-Count"))
|
||||||
|
|
||||||
|
var repos []api.Repository
|
||||||
|
DecodeJSON(t, resp, &repos)
|
||||||
|
assert.Len(t, repos, 1)
|
||||||
|
assert.Equal(t, repo, repos[0].FullName)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("GetMyWatchedRepos", func(t *testing.T) {
|
||||||
|
defer tests.PrintCurrentTest(t)()
|
||||||
|
|
||||||
|
req := NewRequest(t, "GET", fmt.Sprintf("/api/v1/user/subscriptions?token=%s", token))
|
||||||
|
resp := MakeRequest(t, req, http.StatusOK)
|
||||||
|
|
||||||
|
assert.Equal(t, "1", resp.Header().Get("X-Total-Count"))
|
||||||
|
|
||||||
|
var repos []api.Repository
|
||||||
|
DecodeJSON(t, resp, &repos)
|
||||||
|
assert.Len(t, repos, 1)
|
||||||
|
assert.Equal(t, repo, repos[0].FullName)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("IsWatching", func(t *testing.T) {
|
||||||
|
defer tests.PrintCurrentTest(t)()
|
||||||
|
|
||||||
|
req := NewRequest(t, "GET", fmt.Sprintf("/api/v1/repos/%s/subscription?token=%s", repo, token))
|
||||||
|
MakeRequest(t, req, http.StatusOK)
|
||||||
|
|
||||||
|
req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/repos/%s/subscription?token=%s", repo+"notexisting", token))
|
||||||
|
MakeRequest(t, req, http.StatusNotFound)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("Unwatch", func(t *testing.T) {
|
||||||
|
defer tests.PrintCurrentTest(t)()
|
||||||
|
|
||||||
|
req := NewRequest(t, "DELETE", fmt.Sprintf("/api/v1/repos/%s/subscription?token=%s", repo, token))
|
||||||
|
MakeRequest(t, req, http.StatusNoContent)
|
||||||
|
})
|
||||||
|
}
|
Loading…
Reference in a new issue