github.com/gitbundle/modules@v0.0.0-20231025071548-85b91c5c3b01/git/repo_test.go (about)

     1  // Copyright 2023 The GitBundle Inc. All rights reserved.
     2  // Copyright 2017 The Gitea Authors. All rights reserved.
     3  // Use of this source code is governed by a MIT-style
     4  // license that can be found in the LICENSE file.
     5  
     6  package git
     7  
     8  import (
     9  	"path/filepath"
    10  	"testing"
    11  
    12  	"github.com/stretchr/testify/assert"
    13  )
    14  
    15  func TestGetLatestCommitTime(t *testing.T) {
    16  	bareRepo1Path := filepath.Join(testReposDir, "repo1_bare")
    17  	lct, err := GetLatestCommitTime(DefaultContext, bareRepo1Path)
    18  	assert.NoError(t, err)
    19  	// Time is Sun Jul 21 22:43:13 2019 +0200
    20  	// which is the time of commit
    21  	// feaf4ba6bc635fec442f46ddd4512416ec43c2c2 (refs/heads/master)
    22  	assert.EqualValues(t, 1563741793, lct.Unix())
    23  }
    24  
    25  func TestRepoIsEmpty(t *testing.T) {
    26  	emptyRepo2Path := filepath.Join(testReposDir, "repo2_empty")
    27  	repo, err := openRepositoryWithDefaultContext(emptyRepo2Path)
    28  	assert.NoError(t, err)
    29  	defer repo.Close()
    30  	isEmpty, err := repo.IsEmpty()
    31  	assert.NoError(t, err)
    32  	assert.True(t, isEmpty)
    33  }