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.

repo_test.go 893B

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