本站源代码
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

39 行
1.1KB

  1. // Copyright 2019 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 TestGetNotes(t *testing.T) {
  11. bareRepo1Path := filepath.Join(testReposDir, "repo1_bare")
  12. bareRepo1, err := OpenRepository(bareRepo1Path)
  13. assert.NoError(t, err)
  14. note := Note{}
  15. err = GetNote(bareRepo1, "95bb4d39648ee7e325106df01a621c530863a653", &note)
  16. assert.NoError(t, err)
  17. assert.Equal(t, []byte("Note contents\n"), note.Message)
  18. assert.Equal(t, "Vladimir Panteleev", note.Commit.Author.Name)
  19. }
  20. func TestGetNestedNotes(t *testing.T) {
  21. repoPath := filepath.Join(testReposDir, "repo3_notes")
  22. repo, err := OpenRepository(repoPath)
  23. assert.NoError(t, err)
  24. note := Note{}
  25. err = GetNote(repo, "3e668dbfac39cbc80a9ff9c61eb565d944453ba4", &note)
  26. assert.NoError(t, err)
  27. assert.Equal(t, []byte("Note 2"), note.Message)
  28. err = GetNote(repo, "ba0a96fa63532d6c5087ecef070b0250ed72fa47", &note)
  29. assert.NoError(t, err)
  30. assert.Equal(t, []byte("Note 1"), note.Message)
  31. }
上海开阖软件有限公司 沪ICP备12045867号-1