code.gitea.io/gitea@v1.19.3/modules/git/repo_test.go (about)

     1  // Copyright 2017 The Gitea Authors. All rights reserved.
     2  // SPDX-License-Identifier: MIT
     3  
     4  package git
     5  
     6  import (
     7  	"path/filepath"
     8  	"testing"
     9  
    10  	"github.com/stretchr/testify/assert"
    11  )
    12  
    13  func TestGetLatestCommitTime(t *testing.T) {
    14  	bareRepo1Path := filepath.Join(testReposDir, "repo1_bare")
    15  	lct, err := GetLatestCommitTime(DefaultContext, bareRepo1Path)
    16  	assert.NoError(t, err)
    17  	// Time is Sun Nov 13 16:40:14 2022 +0100
    18  	// which is the time of commit
    19  	// ce064814f4a0d337b333e646ece456cd39fab612 (refs/heads/master)
    20  	assert.EqualValues(t, 1668354014, lct.Unix())
    21  }
    22  
    23  func TestRepoIsEmpty(t *testing.T) {
    24  	emptyRepo2Path := filepath.Join(testReposDir, "repo2_empty")
    25  	repo, err := openRepositoryWithDefaultContext(emptyRepo2Path)
    26  	assert.NoError(t, err)
    27  	defer repo.Close()
    28  	isEmpty, err := repo.IsEmpty()
    29  	assert.NoError(t, err)
    30  	assert.True(t, isEmpty)
    31  }