summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/templates
diff options
context:
space:
mode:
authorKallyDev <36319157+kallydev@users.noreply.github.com>2021-09-30 01:17:48 +0800
committerGitHub <noreply@github.com>2021-09-29 11:17:48 -0600
commitc48fadc4a7655008d13076c7f757c36368e2ca13 (patch)
tree3fe2837e02e9b664dd5b86afbe42494ac20997f8 /modules/caddyhttp/templates
parent059fc32f002d00e980b438b3edbdf7b8bcdf9a90 (diff)
Move from deprecated ioutil to os and io packages (#4364)
Diffstat (limited to 'modules/caddyhttp/templates')
-rw-r--r--modules/caddyhttp/templates/tplcontext_test.go9
1 files changed, 4 insertions, 5 deletions
diff --git a/modules/caddyhttp/templates/tplcontext_test.go b/modules/caddyhttp/templates/tplcontext_test.go
index 1d15ca7..c2fe61f 100644
--- a/modules/caddyhttp/templates/tplcontext_test.go
+++ b/modules/caddyhttp/templates/tplcontext_test.go
@@ -17,7 +17,6 @@ package templates
import (
"bytes"
"fmt"
- "io/ioutil"
"net/http"
"os"
"path/filepath"
@@ -118,7 +117,7 @@ func TestImport(t *testing.T) {
// create files for test case
if test.fileName != "" {
absFilePath := filepath.Join(fmt.Sprintf("%s", context.Root), test.fileName)
- if err := ioutil.WriteFile(absFilePath, []byte(test.fileContent), os.ModePerm); err != nil {
+ if err := os.WriteFile(absFilePath, []byte(test.fileContent), os.ModePerm); err != nil {
os.Remove(absFilePath)
t.Fatalf("Test %d: Expected no error creating file, got: '%s'", i, err.Error())
}
@@ -198,7 +197,7 @@ func TestInclude(t *testing.T) {
// create files for test case
if test.fileName != "" {
absFilePath := filepath.Join(fmt.Sprintf("%s", context.Root), test.fileName)
- if err := ioutil.WriteFile(absFilePath, []byte(test.fileContent), os.ModePerm); err != nil {
+ if err := os.WriteFile(absFilePath, []byte(test.fileContent), os.ModePerm); err != nil {
os.Remove(absFilePath)
t.Fatalf("Test %d: Expected no error creating file, got: '%s'", i, err.Error())
}
@@ -357,13 +356,13 @@ func TestFileListing(t *testing.T) {
// create files for test case
if test.fileNames != nil {
- dirPath, err = ioutil.TempDir(fmt.Sprintf("%s", context.Root), "caddy_ctxtest")
+ dirPath, err = os.MkdirTemp(fmt.Sprintf("%s", context.Root), "caddy_ctxtest")
if err != nil {
t.Fatalf("Test %d: Expected no error creating directory, got: '%s'", i, err.Error())
}
for _, name := range test.fileNames {
absFilePath := filepath.Join(dirPath, name)
- if err = ioutil.WriteFile(absFilePath, []byte(""), os.ModePerm); err != nil {
+ if err = os.WriteFile(absFilePath, []byte(""), os.ModePerm); err != nil {
os.RemoveAll(dirPath)
t.Fatalf("Test %d: Expected no error creating file, got: '%s'", i, err.Error())
}