-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Merged
Merged
Add Attachment API #3478
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
25615b1
Add Attachment API
jonasfranz b2a780d
Add unit tests for new attachment functions
jonasfranz 1407c1c
fix lint
80c6555
Update vendor.json
jonasfranz ea14f48
Merge remote-tracking branch 'origin/711-releases-api' into 711-relea…
jonasfranz 95965d8
remove version of sdk
jonasfranz 640ef5a
Fix unit tests
jonasfranz ad41258
Add CreateReleaseAttachment
jonasfranz ca954a7
Add filename query parameter for choosing another name for an attachment
jonasfranz 151f594
Fix order of imports
jonasfranz 030d4e8
Restricting updatable attachment columns
jonasfranz 69539dc
Merge branch 'master' into 711-releases-api
jonasfranz da162ad
gofmt
jonasfranz e3aedec
Merge remote-tracking branch 'origin/711-releases-api' into 711-relea…
jonasfranz 8c6ad76
Merge branch 'master' into 711-releases-api
jonasfranz f55249d
Merge branch 'master' into 711-releases-api
jonasfranz 97ef292
Merge branch 'master' into 711-releases-api
jonasfranz 14f27bb
Merge branch 'master' into 711-releases-api
jonasfranz ffed1a5
Merge branch 'master' into 711-releases-api
jonasfranz b4698a8
Merge branch 'master' into 711-releases-api
jonasfranz 322c7a6
Update go-sdk
jonasfranz 96acb4e
Update go-sdk
jonasfranz b696a63
Merge branch 'master' into 711-releases-api
jonasfranz e5c1b82
Updating go-sdk and regenerating swagger
jonasfranz 62e93ab
Merge remote-tracking branch 'origin/711-releases-api' into 711-relea…
jonasfranz 30258dc
Merge branch 'master' into 711-releases-api
jonasfranz 08c778d
Add missing file of go-sdk
jonasfranz 73b705e
Change origin of code.gitea.io/sdk to code.gitea.io/sdk
jonasfranz b2bdd60
Merge branch 'master' into 711-releases-api
jonasfranz d0d80aa
Merge branch 'master' into 711-releases-api
jonasfranz 555521c
Merge branch 'master' into 711-releases-api
jonasfranz e317350
Update swagger
jonasfranz 410e801
Merge branch 'master' into 711-releases-api
jonasfranz 7a6c7dd
Update updateAttachment
jonasfranz 3812137
Merge branch 'master' into 711-releases-api
jonasfranz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.