Skip to content

Commit

Permalink
remove deprecated ioutil package (#280)
Browse files Browse the repository at this point in the history
  • Loading branch information
chimanjain authored May 29, 2024
1 parent b7bdf39 commit fd7cb3b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
5 changes: 2 additions & 3 deletions deploy/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"fmt"
"io"
"io/fs"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
Expand Down Expand Up @@ -806,7 +805,7 @@ func TestDeployProcess_InstallK3s(t *testing.T) {
osOpenFile = func(name string, _ int, _ os.FileMode) (*os.File, error) {
var err error
// openedFile, err = os.Create(filepath.Join(os.TempDir(), filepath.Base(name)))
openedFile, err = ioutil.TempFile(os.TempDir(), "")
openedFile, err = os.CreateTemp(os.TempDir(), "")
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -873,7 +872,7 @@ func TestDeployProcess_InstallK3s(t *testing.T) {
osOpenFile = func(_ string, _ int, _ os.FileMode) (*os.File, error) {
var err error
// openedFile, err = os.Create(filepath.Join(os.TempDir(), filepath.Base(name)))
openedFile, err = ioutil.TempFile(os.TempDir(), "")
openedFile, err = os.CreateTemp(os.TempDir(), "")
if err != nil {
t.Fatal(err)
}
Expand Down
8 changes: 4 additions & 4 deletions internal/powerflex/token_getter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ package powerflex_test
import (
"context"
"fmt"
"io/ioutil"
"karavi-authorization/internal/powerflex"
"net/http"
"net/http/httptest"
"os"
"testing"
"time"

Expand All @@ -32,7 +32,7 @@ import (
func TestLogin_GetToken(t *testing.T) {
t.Run("success getting a token", func(t *testing.T) {
tokens := make(map[string]interface{})
credFile, err := ioutil.ReadFile("../../tokens.yaml")
credFile, err := os.ReadFile("../../tokens.yaml")
if err != nil {
t.Errorf("unable to read token: %v", err)
}
Expand Down Expand Up @@ -99,7 +99,7 @@ func TestLogin_GetToken(t *testing.T) {

t.Run("success getting a token during refresh", func(t *testing.T) {
tokens := make(map[string]interface{})
credFile, err := ioutil.ReadFile("../../tokens.yaml")
credFile, err := os.ReadFile("../../tokens.yaml")
if err != nil {
t.Errorf("unable to read token: %v", err)
}
Expand Down Expand Up @@ -182,7 +182,7 @@ func TestLogin_GetToken(t *testing.T) {

t.Run("timeout getting a token during refresh", func(t *testing.T) {
tokens := make(map[string]interface{})
credFile, err := ioutil.ReadFile("../../tokens.yaml")
credFile, err := os.ReadFile("../../tokens.yaml")
if err != nil {
t.Errorf("unable to read token: %v", err)
}
Expand Down
3 changes: 1 addition & 2 deletions internal/tenantsvc/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"context"
"encoding/base64"
"fmt"
"io/ioutil"
"karavi-authorization/internal/tenantsvc"
"karavi-authorization/internal/token/jwx"
"karavi-authorization/pb"
Expand Down Expand Up @@ -394,7 +393,7 @@ func testGenerateToken(sut *tenantsvc.TenantService, _ *redis.Client, afterFn Af
func testRefreshToken(sut *tenantsvc.TenantService, _ *redis.Client, afterFn AfterFunc) func(*testing.T) {
return func(t *testing.T) {
tokens := make(map[string]interface{})
credFile, err := ioutil.ReadFile("../../tokens.yaml")
credFile, err := os.ReadFile("../../tokens.yaml")
if err != nil {
t.Errorf("unable to read token: %v", err)
}
Expand Down
6 changes: 3 additions & 3 deletions internal/web/middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ package web_test
import (
"context"
"errors"
"io/ioutil"
"karavi-authorization/internal/token/jwx"
"karavi-authorization/internal/web"
"karavi-authorization/pb"
"net/http"
"net/http/httptest"
"os"
"testing"

"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -122,7 +122,7 @@ func TestAuthMW(t *testing.T) {

// test token
tokens := make(map[string]interface{})
credFile, err := ioutil.ReadFile("../../tokens.yaml")
credFile, err := os.ReadFile("../../tokens.yaml")
if err != nil {
t.Errorf("unable to read token: %v", err)
}
Expand All @@ -149,7 +149,7 @@ func TestAuthMW(t *testing.T) {

// test token
tokens := make(map[string]interface{})
credFile, err := ioutil.ReadFile("../../tokens.yaml")
credFile, err := os.ReadFile("../../tokens.yaml")
if err != nil {
t.Errorf("unable to read token: %v", err)
}
Expand Down

0 comments on commit fd7cb3b

Please sign in to comment.