mirror of
https://github.com/go-gitea/gitea.git
synced 2024-08-27 22:04:28 -04:00
* move code.gitea.io/git to code.gitea.io/gitea/modules/git * fix imports * fix fmt * fix misspell * remove wrong tests data * fix unit tests * fix tests * fix tests * fix tests * fix tests * fix tests * enable Debug to trace the failure tests * fix tests * fix tests * fix tests * fix tests * fix tests * comment commit count tests since git clone depth is 50 * fix tests * update from code.gitea.io/git * revert change to makefile
45 lines
1.3 KiB
Go
45 lines
1.3 KiB
Go
// Copyright 2019 The Gitea Authors. All rights reserved.
|
|
// Use of this source code is governed by a MIT-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package git
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestRepository_GetTags(t *testing.T) {
|
|
bareRepo1Path := filepath.Join(testReposDir, "repo1_bare")
|
|
bareRepo1, err := OpenRepository(bareRepo1Path)
|
|
assert.NoError(t, err)
|
|
|
|
tags, err := bareRepo1.GetTagInfos()
|
|
assert.NoError(t, err)
|
|
assert.Len(t, tags, 1)
|
|
assert.EqualValues(t, "test", tags[0].Name)
|
|
assert.EqualValues(t, "37991dec2c8e592043f47155ce4808d4580f9123", tags[0].ID.String())
|
|
assert.EqualValues(t, "commit", tags[0].Type)
|
|
}
|
|
|
|
func TestRepository_GetTag(t *testing.T) {
|
|
bareRepo1Path := filepath.Join(testReposDir, "repo1_bare")
|
|
|
|
clonedPath, err := cloneRepo(bareRepo1Path, testReposDir, "repo1_TestRepository_GetTag")
|
|
assert.NoError(t, err)
|
|
defer os.RemoveAll(clonedPath)
|
|
|
|
bareRepo1, err := OpenRepository(clonedPath)
|
|
assert.NoError(t, err)
|
|
|
|
tag, err := bareRepo1.GetTag("test")
|
|
assert.NoError(t, err)
|
|
assert.NotNil(t, tag)
|
|
assert.EqualValues(t, "test", tag.Name)
|
|
assert.EqualValues(t, "37991dec2c8e592043f47155ce4808d4580f9123", tag.ID.String())
|
|
assert.EqualValues(t, "commit", tag.Type)
|
|
}
|