mirror of
https://github.com/go-gitea/gitea
synced 2024-12-23 09:04:26 +00:00
f2e7d5477f
The io/ioutil package has been deprecated as of Go 1.16, see https://golang.org/doc/go1.16#ioutil. This commit replaces the existing io/ioutil functions with their new definitions in io and os packages. Signed-off-by: Eng Zer Jun <engzerjun@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
34 lines
919 B
Go
34 lines
919 B
Go
// Copyright 2018 The Gitea Authors. All rights reserved.
|
|
// Use of this source code is governed by a MIT-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package git
|
|
|
|
import (
|
|
"bytes"
|
|
"io"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"code.gitea.io/gitea/modules/util"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestGetFormatPatch(t *testing.T) {
|
|
bareRepo1Path := filepath.Join(testReposDir, "repo1_bare")
|
|
clonedPath, err := cloneRepo(bareRepo1Path, testReposDir, "repo1_TestGetFormatPatch")
|
|
assert.NoError(t, err)
|
|
defer util.RemoveAll(clonedPath)
|
|
repo, err := OpenRepository(clonedPath)
|
|
assert.NoError(t, err)
|
|
defer repo.Close()
|
|
rd := &bytes.Buffer{}
|
|
err = repo.GetPatch("8d92fc95^", "8d92fc95", rd)
|
|
assert.NoError(t, err)
|
|
patchb, err := io.ReadAll(rd)
|
|
assert.NoError(t, err)
|
|
patch := string(patchb)
|
|
assert.Regexp(t, "^From 8d92fc95", patch)
|
|
assert.Contains(t, patch, "Subject: [PATCH] Add file2.txt")
|
|
}
|