Skip to content

Commit

Permalink
Replace deprecated function calls
Browse files Browse the repository at this point in the history
Signed-off-by: Maksym Pavlenko <[email protected]>
  • Loading branch information
mxpv committed Apr 1, 2024
1 parent d8e042a commit e784990
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 21 deletions.
4 changes: 2 additions & 2 deletions cmd/podsync/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"regexp"

Expand Down Expand Up @@ -54,7 +54,7 @@ type Log struct {

// LoadConfig loads TOML configuration from a file path
func LoadConfig(path string) (*Config, error) {
data, err := ioutil.ReadFile(path)
data, err := os.ReadFile(path)
if err != nil {
return nil, errors.Wrapf(err, "failed to read config file: %s", path)
}
Expand Down
21 changes: 4 additions & 17 deletions pkg/fs/local_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ package fs
import (
"bytes"
"context"
"io/ioutil"
"os"
"path/filepath"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

var (
Expand All @@ -23,10 +21,7 @@ func TestNewLocal(t *testing.T) {
}

func TestLocal_Create(t *testing.T) {
tmpDir, err := ioutil.TempDir("", "podsync-local-stor-")
require.NoError(t, err)

defer os.RemoveAll(tmpDir)
tmpDir := t.TempDir()

stor, err := NewLocal(tmpDir)
assert.NoError(t, err)
Expand All @@ -41,8 +36,7 @@ func TestLocal_Create(t *testing.T) {
}

func TestLocal_Size(t *testing.T) {
tmpDir, err := ioutil.TempDir("", "podsync-local-stor-")
require.NoError(t, err)
tmpDir := t.TempDir()

defer os.RemoveAll(tmpDir)

Expand All @@ -66,10 +60,7 @@ func TestLocal_NoSize(t *testing.T) {
}

func TestLocal_Delete(t *testing.T) {
tmpDir, err := ioutil.TempDir("", "podsync-local-stor-")
require.NoError(t, err)

defer os.RemoveAll(tmpDir)
tmpDir := t.TempDir()

stor, err := NewLocal(tmpDir)
assert.NoError(t, err)
Expand All @@ -89,11 +80,7 @@ func TestLocal_Delete(t *testing.T) {

func TestLocal_copyFile(t *testing.T) {
reader := bytes.NewReader([]byte{1, 2, 4})

tmpDir, err := ioutil.TempDir("", "podsync-test-")
require.NoError(t, err)

defer os.RemoveAll(tmpDir)
tmpDir := t.TempDir()

file := filepath.Join(tmpDir, "1")

Expand Down
4 changes: 2 additions & 2 deletions pkg/fs/s3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package fs

import (
"bytes"
"io/ioutil"
"io"
"os"
"testing"

Expand Down Expand Up @@ -98,7 +98,7 @@ func newMockS3(files map[string][]byte, prefix string) (*S3, error) {
}

func (m *mockS3API) PutObjectRequest(input *s3.PutObjectInput) (*request.Request, *s3.PutObjectOutput) {
content, _ := ioutil.ReadAll(input.Body)
content, _ := io.ReadAll(input.Body)
req := request.New(aws.Config{}, metadata.ClientInfo{}, request.Handlers{}, nil, &request.Operation{}, nil, nil)
m.files[*input.Key] = content
return req, &s3.PutObjectOutput{}
Expand Down

0 comments on commit e784990

Please sign in to comment.