2021-07-27 17:39:21 +02:00
|
|
|
package file
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
"os"
|
|
|
|
|
"path"
|
|
|
|
|
"testing"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// 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...)
|
2024-10-08 10:17:25 -04:00
|
|
|
file, err := os.ReadFile(modelFilePath) // #nosec G304
|
2021-07-27 17:39:21 +02:00
|
|
|
require.Nil(t, err)
|
|
|
|
|
require.NotEmpty(t, file)
|
|
|
|
|
return string(file)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// NotExists expects file not to exist on path constructed from pathElems
|
|
|
|
|
func NotExists(t *testing.T, pathElems ...string) {
|
|
|
|
|
modelFilePath := path.Join(pathElems...)
|
2024-10-08 10:17:25 -04:00
|
|
|
_, err := os.ReadFile(modelFilePath) // #nosec G304
|
2021-07-27 17:39:21 +02:00
|
|
|
require.True(t, os.IsNotExist(err))
|
|
|
|
|
}
|