mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-02 12:41:29 +00:00
@@ -13,6 +13,7 @@ import (
|
||||
api "gitea.dev/modules/structs"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestToCommitMeta(t *testing.T) {
|
||||
@@ -38,3 +39,21 @@ func TestToCommitMeta(t *testing.T) {
|
||||
Created: time.Unix(0, 0),
|
||||
}, commitMeta)
|
||||
}
|
||||
|
||||
func TestToCommitTree(t *testing.T) {
|
||||
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
|
||||
signature := &git.Signature{Name: "Test Signature", Email: "test@email.com", When: time.Unix(0, 0)}
|
||||
commit := &git.Commit{
|
||||
ID: git.MustIDFromString("65f1bf27bc3bf70f64657658635e66094edbcb4d"),
|
||||
TreeID: git.MustIDFromString("2a2f1d4670728a2e10049e345bd7a276468beab6"),
|
||||
Author: signature,
|
||||
Committer: signature,
|
||||
}
|
||||
|
||||
apiCommit, err := ToCommit(t.Context(), repo, nil, commit, nil, ToCommitOptions{})
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "2a2f1d4670728a2e10049e345bd7a276468beab6", apiCommit.RepoCommit.Tree.SHA)
|
||||
assert.Equal(t, repo.APIURL()+"/git/trees/2a2f1d4670728a2e10049e345bd7a276468beab6", apiCommit.RepoCommit.Tree.URL)
|
||||
assert.Equal(t, "65f1bf27bc3bf70f64657658635e66094edbcb4d", apiCommit.SHA)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user