mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 19:06:18 +01:00 
			
		
		
		
	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>
This commit is contained in:
		| @@ -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 | ||||
| 			} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user