aboutsummaryrefslogtreecommitdiffstats
path: root/integrations/git_helper_for_declarative_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_helper_for_declarative_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_helper_for_declarative_test.go')
-rw-r--r--integrations/git_helper_for_declarative_test.go9
1 files changed, 4 insertions, 5 deletions
diff --git a/integrations/git_helper_for_declarative_test.go b/integrations/git_helper_for_declarative_test.go
index 5a5b1314c6..9da5c05f94 100644
--- a/integrations/git_helper_for_declarative_test.go
+++ b/integrations/git_helper_for_declarative_test.go
@@ -7,7 +7,6 @@ package integrations
import (
"context"
"fmt"
- "io/ioutil"
"net"
"net/http"
"net/url"
@@ -28,7 +27,7 @@ import (
func withKeyFile(t *testing.T, keyname string, callback func(string)) {
- tmpDir, err := ioutil.TempDir("", "key-file")
+ tmpDir, err := os.MkdirTemp("", "key-file")
assert.NoError(t, err)
defer util.RemoveAll(tmpDir)
@@ -39,7 +38,7 @@ func withKeyFile(t *testing.T, keyname string, callback func(string)) {
err = ssh.GenKeyPair(keyFile)
assert.NoError(t, err)
- err = ioutil.WriteFile(path.Join(tmpDir, "ssh"), []byte("#!/bin/bash\n"+
+ err = os.WriteFile(path.Join(tmpDir, "ssh"), []byte("#!/bin/bash\n"+
"ssh -o \"UserKnownHostsFile=/dev/null\" -o \"StrictHostKeyChecking=no\" -o \"IdentitiesOnly=yes\" -i \""+keyFile+"\" \"$@\""), 0700)
assert.NoError(t, err)
@@ -125,7 +124,7 @@ func doGitClone(dstLocalPath string, u *url.URL) func(*testing.T) {
func doGitCloneFail(u *url.URL) func(*testing.T) {
return func(t *testing.T) {
- tmpDir, err := ioutil.TempDir("", "doGitCloneFail")
+ tmpDir, err := os.MkdirTemp("", "doGitCloneFail")
assert.NoError(t, err)
defer util.RemoveAll(tmpDir)
assert.Error(t, git.Clone(u.String(), tmpDir, git.CloneRepoOptions{}))
@@ -139,7 +138,7 @@ func doGitInitTestRepository(dstPath string) func(*testing.T) {
return func(t *testing.T) {
// Init repository in dstPath
assert.NoError(t, git.InitRepository(dstPath, false))
- assert.NoError(t, ioutil.WriteFile(filepath.Join(dstPath, "README.md"), []byte(fmt.Sprintf("# Testing Repository\n\nOriginally created in: %s", dstPath)), 0644))
+ assert.NoError(t, os.WriteFile(filepath.Join(dstPath, "README.md"), []byte(fmt.Sprintf("# Testing Repository\n\nOriginally created in: %s", dstPath)), 0644))
assert.NoError(t, git.AddChanges(dstPath, true))
signature := git.Signature{
Email: "test@example.com",