mirror of https://github.com/go-gitea/gitea
Git with a cup of tea, painless self-hosted git service
Mirror for internal git.with.parts use
https://git.with.parts
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.2 KiB
42 lines
1.2 KiB
4 years ago
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||
2 years ago
|
// SPDX-License-Identifier: MIT
|
||
4 years ago
|
|
||
|
package convert
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
"time"
|
||
|
|
||
3 years ago
|
repo_model "code.gitea.io/gitea/models/repo"
|
||
3 years ago
|
"code.gitea.io/gitea/models/unittest"
|
||
4 years ago
|
"code.gitea.io/gitea/modules/git"
|
||
|
api "code.gitea.io/gitea/modules/structs"
|
||
|
"code.gitea.io/gitea/modules/util"
|
||
|
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
)
|
||
|
|
||
|
func TestToCommitMeta(t *testing.T) {
|
||
3 years ago
|
assert.NoError(t, unittest.PrepareTestDatabase())
|
||
2 years ago
|
headRepo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
|
||
4 years ago
|
sha1, _ := git.NewIDFromString("0000000000000000000000000000000000000000")
|
||
4 years ago
|
signature := &git.Signature{Name: "Test Signature", Email: "test@email.com", When: time.Unix(0, 0)}
|
||
4 years ago
|
tag := &git.Tag{
|
||
|
Name: "Test Tag",
|
||
|
ID: sha1,
|
||
|
Object: sha1,
|
||
|
Type: "Test Type",
|
||
|
Tagger: signature,
|
||
|
Message: "Test Message",
|
||
|
}
|
||
|
|
||
|
commitMeta := ToCommitMeta(headRepo, tag)
|
||
|
|
||
|
assert.NotNil(t, commitMeta)
|
||
|
assert.EqualValues(t, &api.CommitMeta{
|
||
|
SHA: "0000000000000000000000000000000000000000",
|
||
|
URL: util.URLJoin(headRepo.APIURL(), "git/commits", "0000000000000000000000000000000000000000"),
|
||
|
Created: time.Unix(0, 0),
|
||
|
}, commitMeta)
|
||
|
}
|