mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-08-20 09:21:11 +00:00
Mainly a port of https://github.com/go-gitea/gitea/pull/31082. closes #3573 ## Screenshots   --- ## Checklist ### Tests - I added test coverage for Go changes... - [x] in their respective `*_test.go` for unit tests. - [ ] in the `tests/integration` directory if it involves interactions with a live Forgejo server. - I added test coverage for JavaScript changes... - [ ] in `web_src/js/*.test.js` if it can be unit tested. - [ ] in `tests/e2e/*.test.e2e.js` if it requires interactions with a live Forgejo server (see also the [developer guide for JavaScript testing](https://codeberg.org/forgejo/forgejo/src/branch/forgejo/tests/e2e/README.md#end-to-end-tests)). ### Documentation - [ ] I created a pull request [to the documentation](https://codeberg.org/forgejo/docs) to explain to Forgejo users how to use this change. - [x] I did not document these changes and I do not expect someone else to do it. ### Release notes - [ ] I do not want this change to show in the release notes. - [x] I want the title to show in the release notes with a link to this pull request. - [ ] I want the content of the `release-notes/<pull request number>.md` to be be used for the release notes instead of the title. <!--start release-notes-assistant--> ## Release notes <!--URL:https://codeberg.org/forgejo/forgejo--> - User Interface features - [PR](https://codeberg.org/forgejo/forgejo/pulls/8759): <!--number 8759 --><!--line 0 --><!--description YWRkIHRhZyBsYWJlbCB0byBjb21taXQgbGlzdCB2aWV3-->add tag label to commit list view<!--description--> <!--end release-notes-assistant--> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8759 Reviewed-by: Gusted <gusted@noreply.codeberg.org> Co-authored-by: pat-s <patrick.schratz@gmail.com> Co-committed-by: pat-s <patrick.schratz@gmail.com>
64 lines
1.6 KiB
Go
64 lines
1.6 KiB
Go
// Copyright 2023 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package repo
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"forgejo.org/models/db"
|
|
"forgejo.org/models/unittest"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestMigrate_InsertReleases(t *testing.T) {
|
|
require.NoError(t, unittest.PrepareTestDatabase())
|
|
|
|
a := &Attachment{
|
|
UUID: "a0eebc91-9c0c-4ef7-bb6e-6bb9bd380a12",
|
|
}
|
|
r := &Release{
|
|
Attachments: []*Attachment{a},
|
|
}
|
|
|
|
err := InsertReleases(db.DefaultContext, r)
|
|
require.NoError(t, err)
|
|
}
|
|
|
|
func TestReleaseLoadRepo(t *testing.T) {
|
|
require.NoError(t, unittest.PrepareTestDatabase())
|
|
|
|
release := unittest.AssertExistsAndLoadBean(t, &Release{ID: 1})
|
|
assert.Nil(t, release.Repo)
|
|
|
|
require.NoError(t, release.LoadRepo(db.DefaultContext))
|
|
|
|
assert.EqualValues(t, 1, release.Repo.ID)
|
|
}
|
|
|
|
func TestReleaseDisplayName(t *testing.T) {
|
|
release := Release{TagName: "TagName"}
|
|
|
|
assert.Empty(t, release.DisplayName())
|
|
|
|
release.IsTag = true
|
|
assert.Equal(t, "TagName", release.DisplayName())
|
|
|
|
release.Title = "Title"
|
|
assert.Equal(t, "Title", release.DisplayName())
|
|
}
|
|
|
|
func Test_FindTagsByCommitIDs(t *testing.T) {
|
|
require.NoError(t, unittest.PrepareTestDatabase())
|
|
|
|
sha1Rels, err := FindTagsByCommitIDs(db.DefaultContext, 1, "65f1bf27bc3bf70f64657658635e66094edbcb4d")
|
|
require.NoError(t, err)
|
|
assert.Len(t, sha1Rels, 1)
|
|
rels := sha1Rels["65f1bf27bc3bf70f64657658635e66094edbcb4d"]
|
|
assert.Len(t, rels, 3)
|
|
assert.Equal(t, "v1.1", rels[0].TagName)
|
|
assert.Equal(t, "delete-tag", rels[1].TagName)
|
|
assert.Equal(t, "v1.0", rels[2].TagName)
|
|
}
|