summaryrefslogtreecommitdiffstats
path: root/integrations/git_test.go
diff options
context:
space:
mode:
authorEng Zer Jun <engzerjun@gmail.com>2021-09-22 13:38:34 +0800
committerGitHub <noreply@github.com>2021-09-22 13:38:34 +0800
commitf2e7d5477f076789da5d0e95fe61a56ddb939f5a (patch)
tree922ca8769761c30e93f3b4deaf27858026b27ebf /integrations/git_test.go
parentaa631d8cd18251aa9b18ce72f75c8d8c7090e5e7 (diff)
downloadgitea-f2e7d5477f076789da5d0e95fe61a56ddb939f5a.tar.gz
gitea-f2e7d5477f076789da5d0e95fe61a56ddb939f5a.zip
refactor: move from io/ioutil to io and os package (#17109)
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>
Diffstat (limited to 'integrations/git_test.go')
-rw-r--r--integrations/git_test.go16
1 files changed, 8 insertions, 8 deletions
diff --git a/integrations/git_test.go b/integrations/git_test.go
index 72e01d3753..9a264c9448 100644
--- a/integrations/git_test.go
+++ b/integrations/git_test.go
@@ -7,10 +7,10 @@ package integrations
import (
"encoding/hex"
"fmt"
- "io/ioutil"
"math/rand"
"net/http"
"net/url"
+ "os"
"path"
"path/filepath"
"strconv"
@@ -52,7 +52,7 @@ func testGit(t *testing.T, u *url.URL) {
httpContext.Reponame = "repo-tmp-17"
forkedUserCtx.Reponame = httpContext.Reponame
- dstPath, err := ioutil.TempDir("", httpContext.Reponame)
+ dstPath, err := os.MkdirTemp("", httpContext.Reponame)
assert.NoError(t, err)
defer util.RemoveAll(dstPath)
@@ -102,7 +102,7 @@ func testGit(t *testing.T, u *url.URL) {
sshURL := createSSHUrl(sshContext.GitPath(), u)
//Setup clone folder
- dstPath, err := ioutil.TempDir("", sshContext.Reponame)
+ dstPath, err := os.MkdirTemp("", sshContext.Reponame)
assert.NoError(t, err)
defer util.RemoveAll(dstPath)
@@ -128,7 +128,7 @@ func testGit(t *testing.T, u *url.URL) {
}
func ensureAnonymousClone(t *testing.T, u *url.URL) {
- dstLocalPath, err := ioutil.TempDir("", "repo1")
+ dstLocalPath, err := os.MkdirTemp("", "repo1")
assert.NoError(t, err)
defer util.RemoveAll(dstLocalPath)
t.Run("CloneAnonymous", doGitClone(dstLocalPath, u))
@@ -311,7 +311,7 @@ func generateCommitWithNewData(size int, repoPath, email, fullName, prefix strin
buffer := make([]byte, bufSize)
- tmpFile, err := ioutil.TempFile(repoPath, prefix)
+ tmpFile, err := os.CreateTemp(repoPath, prefix)
if err != nil {
return "", err
}
@@ -558,7 +558,7 @@ func doPushCreate(ctx APITestContext, u *url.URL) func(t *testing.T) {
u.Path = ctx.GitPath()
// Create a temporary directory
- tmpDir, err := ioutil.TempDir("", ctx.Reponame)
+ tmpDir, err := os.MkdirTemp("", ctx.Reponame)
assert.NoError(t, err)
defer util.RemoveAll(tmpDir)
@@ -636,7 +636,7 @@ func doCreateAgitFlowPull(dstPath string, ctx *APITestContext, baseBranch, headB
t.Run("CreateHeadBranch", doGitCreateBranch(dstPath, headBranch))
t.Run("AddCommit", func(t *testing.T) {
- err := ioutil.WriteFile(path.Join(dstPath, "test_file"), []byte("## test content"), 0666)
+ err := os.WriteFile(path.Join(dstPath, "test_file"), []byte("## test content"), 0666)
if !assert.NoError(t, err) {
return
}
@@ -710,7 +710,7 @@ func doCreateAgitFlowPull(dstPath string, ctx *APITestContext, baseBranch, headB
}
t.Run("AddCommit2", func(t *testing.T) {
- err := ioutil.WriteFile(path.Join(dstPath, "test_file"), []byte("## test content \n ## test content 2"), 0666)
+ err := os.WriteFile(path.Join(dstPath, "test_file"), []byte("## test content \n ## test content 2"), 0666)
if !assert.NoError(t, err) {
return
}