-
-
Couldn't load subscription status.
- Fork 6.2k
Add Attachment API #3478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Attachment API #3478
Changes from all commits
25615b1
b2a780d
1407c1c
80c6555
ea14f48
95965d8
640ef5a
ad41258
ca954a7
151f594
030d4e8
69539dc
da162ad
e3aedec
8c6ad76
f55249d
97ef292
14f27bb
ffed1a5
b4698a8
322c7a6
96acb4e
b696a63
e5c1b82
62e93ab
30258dc
08c778d
73b705e
b2bdd60
d0d80aa
555521c
e317350
410e801
7a6c7dd
3812137
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,3 +58,32 @@ func TestDeleteAttachments(t *testing.T) { | |
| assert.True(t, IsErrAttachmentNotExist(err)) | ||
| assert.Nil(t, attachment) | ||
| } | ||
|
|
||
| func TestGetAttachmentByID(t *testing.T) { | ||
| assert.NoError(t, PrepareTestDatabase()) | ||
|
|
||
| attach, err := GetAttachmentByID(1) | ||
| assert.NoError(t, err) | ||
| assert.Equal(t, "a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11", attach.UUID) | ||
| } | ||
|
|
||
| func TestAttachment_DownloadURL(t *testing.T) { | ||
| attach := &Attachment{ | ||
| UUID: "a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11", | ||
| ID: 1, | ||
| } | ||
| assert.Equal(t, "https://try.gitea.io/attachments/a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11", attach.DownloadURL()) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is required because assets is only used at the release API. And the attachment API uses attachment and a change would be breaking. |
||
| } | ||
|
|
||
| func TestUpdateAttachment(t *testing.T) { | ||
| assert.NoError(t, PrepareTestDatabase()) | ||
|
|
||
| attach, err := GetAttachmentByID(1) | ||
| assert.NoError(t, err) | ||
| assert.Equal(t, "a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11", attach.UUID) | ||
|
|
||
| attach.Name = "new_name" | ||
| assert.NoError(t, UpdateAttachment(attach)) | ||
|
|
||
| AssertExistsAndLoadBean(t, &Attachment{Name: "new_name"}) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,4 +4,4 @@ | |
| "less": "^2.7.2", | ||
| "less-plugin-clean-css": "^1.5.1" | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unrelated since it is used to generade the download link and not for API usage.