Skip to content

Commit

Permalink
configuring tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sapk committed Aug 24, 2019
1 parent b72b3eb commit b55f632
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 2 deletions.
21 changes: 21 additions & 0 deletions models/attachment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,24 @@ func TestUpdateAttachment(t *testing.T) {

AssertExistsAndLoadBean(t, &Attachment{Name: "new_name"})
}

func TestAttachment_IsLinked(t *testing.T) {
assert.NoError(t, PrepareTestDatabase())
tests := []struct {
name string
UUID string
want bool
}{
{"comment_linked", "a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a17", true},
{"issue_linked", "a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a18", true},
{"release_linked", "a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a19", true},
{"not_linked", "a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a20", false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
a, err := GetAttachmentByUUID(tt.UUID)
assert.NoError(t, err)
assert.Equal(t, tt.want, a.IsLinked())
})
}
}
15 changes: 15 additions & 0 deletions models/fixtures/attachment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,18 @@
name: attach1
download_count: 0
created_unix: 946684800

-
id: 9
uuid: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a19
release_id: 1
name: attach1
download_count: 0
created_unix: 946684800

-
id: 10
uuid: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a20
name: attach1
download_count: 0
created_unix: 946684800
15 changes: 14 additions & 1 deletion models/fixtures/release.yml
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
[] # empty
-
id: 1
repo_id: 1
publisher_id: 2
tag_name: "testing"
lower_tag_name: "testing"
target: "master"
title: "testing-release"
sha1: "1377085260899283ce483702e6a1723223f7b371"
num_commits: 10
is_draft: false
is_prerelease: false
is_tag: false
created_unix: 946684800
2 changes: 1 addition & 1 deletion routers/routes/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ func RegisterRoutes(m *macaron.Macaron) {
} else {
ctx.Error(404)
}

//If we have matched a access release or issue
fr, err := os.Open(attach.LocalPath())
if err != nil {
Expand Down

0 comments on commit b55f632

Please sign in to comment.