Files
lotherk 1b490485ff refactor: import Gotea from Gitea v28.4.0
Rename the main module to gotea.dev and the binary to gotea, and update the application name and English locale. Keep the external gitea.dev/sdk and gitea.dev/actionslib module imports unchanged.

Assisted-by: OpenCode:DeepSeek-V4.1-Flash
2026-11-22 12:13:09 +00:00

32 lines
1.1 KiB
Go

// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package convert
import (
"testing"
repo_model "gotea.dev/models/repo"
"gotea.dev/models/unittest"
"github.com/stretchr/testify/assert"
)
func TestRelease_ToRelease(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
repo1 := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
release1 := unittest.AssertExistsAndLoadBean(t, &repo_model.Release{ID: 1})
release1.LoadAttributes(t.Context())
apiRelease := ToAPIRelease(t.Context(), repo1, release1)
assert.NotNil(t, apiRelease)
assert.EqualValues(t, 1, apiRelease.ID)
assert.Equal(t, "https://try.gitea.io/api/v1/repos/user2/repo1/releases/1", apiRelease.URL)
assert.Equal(t, "https://try.gitea.io/api/v1/repos/user2/repo1/releases/1/assets", apiRelease.UploadURL)
assert.Equal(t, release1.PublishedUnix.AsTimePtr(), apiRelease.PublishedAt)
release1.IsDraft = true
assert.Nil(t, ToAPIRelease(t.Context(), repo1, release1).PublishedAt, "an unpublished release has no publication date")
}