code.gitea.io/gitea@v1.21.7/services/convert/release_test.go (about)

     1  // Copyright 2023 The Gitea Authors. All rights reserved.
     2  // SPDX-License-Identifier: MIT
     3  
     4  package convert
     5  
     6  import (
     7  	"testing"
     8  
     9  	"code.gitea.io/gitea/models/db"
    10  	repo_model "code.gitea.io/gitea/models/repo"
    11  	"code.gitea.io/gitea/models/unittest"
    12  
    13  	"github.com/stretchr/testify/assert"
    14  )
    15  
    16  func TestRelease_ToRelease(t *testing.T) {
    17  	assert.NoError(t, unittest.PrepareTestDatabase())
    18  
    19  	repo1 := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
    20  	release1 := unittest.AssertExistsAndLoadBean(t, &repo_model.Release{ID: 1})
    21  	release1.LoadAttributes(db.DefaultContext)
    22  
    23  	apiRelease := ToAPIRelease(db.DefaultContext, repo1, release1)
    24  	assert.NotNil(t, apiRelease)
    25  	assert.EqualValues(t, 1, apiRelease.ID)
    26  	assert.EqualValues(t, "https://try.gitea.io/api/v1/repos/user2/repo1/releases/1", apiRelease.URL)
    27  	assert.EqualValues(t, "https://try.gitea.io/api/v1/repos/user2/repo1/releases/1/assets", apiRelease.UploadURL)
    28  }