aboutsummaryrefslogtreecommitdiffstats
path: root/models/attachment_test.go
diff options
context:
space:
mode:
authorJonas Franz <info@jonasfranz.software>2018-03-06 02:22:16 +0100
committerBo-Yi Wu <appleboy.tw@gmail.com>2018-03-06 09:22:16 +0800
commit9a5e628a7e8bc8e7de6ed05f3621442de3388086 (patch)
tree07bd2cc6c22bae9ea976f5c23359d9b5cbf0bd8c /models/attachment_test.go
parent69ea5e438538863056af3bd70d182096b68f0d4a (diff)
downloadgitea-9a5e628a7e8bc8e7de6ed05f3621442de3388086.tar.gz
gitea-9a5e628a7e8bc8e7de6ed05f3621442de3388086.zip
Add Attachment API (#3478)
* Add Attachment API * repos/:owner/:repo/releases (add attachments) * repos/:owner/:repo/releases/:id (add attachments) * repos/:owner/:repo/releases/:id/attachments * repos/:owner/:repo/releases/:id/attachments/:attachment_id Signed-off-by: Jonas Franz <info@jonasfranz.de> * Add unit tests for new attachment functions Fix comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * fix lint * Update vendor.json Signed-off-by: Jonas Franz <info@jonasfranz.software> * remove version of sdk Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix unit tests Add missing license header Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add CreateReleaseAttachment Add EditReleaseAttachment Add DeleteReleaseAttachment Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add filename query parameter for choosing another name for an attachment Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix order of imports Signed-off-by: Jonas Franz <info@jonasfranz.software> * Restricting updatable attachment columns Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update go-sdk Replace Attachments with Assets Signed-off-by: Jonas Franz <info@jonasfranz.de> * Update go-sdk Signed-off-by: Jonas Franz <info@jonasfranz.de> * Updating go-sdk and regenerating swagger Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add missing file of go-sdk Signed-off-by: Jonas Franz <info@jonasfranz.software> * Change origin of code.gitea.io/sdk to code.gitea.io/sdk Update code.gitea.io/sdk Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update swagger Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update updateAttachment
Diffstat (limited to 'models/attachment_test.go')
-rw-r--r--models/attachment_test.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/models/attachment_test.go b/models/attachment_test.go
index d568e39431..be4baf3055 100644
--- a/models/attachment_test.go
+++ b/models/attachment_test.go
@@ -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())
+}
+
+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"})
+}