A fork of Gitea (see branch `mj`) adding Majority Judgment Polls 𐄷 over Issues and Merge Requests. https://git.mieuxvoter.fr
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.

33 lines
930 B

  1. // Copyright 2018 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. "bytes"
  7. "io/ioutil"
  8. "path/filepath"
  9. "testing"
  10. "code.gitea.io/gitea/modules/util"
  11. "github.com/stretchr/testify/assert"
  12. )
  13. func TestGetFormatPatch(t *testing.T) {
  14. bareRepo1Path := filepath.Join(testReposDir, "repo1_bare")
  15. clonedPath, err := cloneRepo(bareRepo1Path, testReposDir, "repo1_TestGetFormatPatch")
  16. assert.NoError(t, err)
  17. defer util.RemoveAll(clonedPath)
  18. repo, err := OpenRepository(clonedPath)
  19. assert.NoError(t, err)
  20. defer repo.Close()
  21. rd := &bytes.Buffer{}
  22. err = repo.GetPatch("8d92fc95^", "8d92fc95", rd)
  23. assert.NoError(t, err)
  24. patchb, err := ioutil.ReadAll(rd)
  25. assert.NoError(t, err)
  26. patch := string(patchb)
  27. assert.Regexp(t, "^From 8d92fc95", patch)
  28. assert.Contains(t, patch, "Subject: [PATCH] Add file2.txt")
  29. }