Replacing several test util function with a generic version
ChangeLog: - updated several test utils with a generic PtrOf - updated references using iotils (Deprecated) with os equivalent import.
This commit is contained in:
parent
6a0798eb06
commit
99be328e9d
15 changed files with 144 additions and 211 deletions
|
|
@ -2,7 +2,6 @@ package file
|
|||
|
||||
import (
|
||||
"github.com/stretchr/testify/require"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"testing"
|
||||
|
|
@ -11,7 +10,7 @@ import (
|
|||
// Exists expects file to exist on path constructed from pathElems and returns content of the file
|
||||
func Exists(t *testing.T, pathElems ...string) (fileContent string) {
|
||||
modelFilePath := path.Join(pathElems...)
|
||||
file, err := ioutil.ReadFile(modelFilePath)
|
||||
file, err := os.ReadFile(modelFilePath)
|
||||
require.Nil(t, err)
|
||||
require.NotEmpty(t, file)
|
||||
return string(file)
|
||||
|
|
@ -20,6 +19,6 @@ func Exists(t *testing.T, pathElems ...string) (fileContent string) {
|
|||
// NotExists expects file not to exist on path constructed from pathElems
|
||||
func NotExists(t *testing.T, pathElems ...string) {
|
||||
modelFilePath := path.Join(pathElems...)
|
||||
_, err := ioutil.ReadFile(modelFilePath)
|
||||
_, err := os.ReadFile(modelFilePath)
|
||||
require.True(t, os.IsNotExist(err))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue