mirror of
https://github.com/grafana/grafana.git
synced 2024-12-01 21:19:28 -06:00
062d255124
* replace ioutil.ReadFile -> os.ReadFile * replace ioutil.ReadAll -> io.ReadAll * replace ioutil.TempFile -> os.CreateTemp * replace ioutil.NopCloser -> io.NopCloser * replace ioutil.WriteFile -> os.WriteFile * replace ioutil.TempDir -> os.MkdirTemp * replace ioutil.Discard -> io.Discard
40 lines
656 B
Go
40 lines
656 B
Go
package fs
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestExists_NonExistent(t *testing.T) {
|
|
exists, err := Exists("non-existent")
|
|
require.NoError(t, err)
|
|
|
|
require.False(t, exists)
|
|
}
|
|
|
|
func TestExists_Existent(t *testing.T) {
|
|
f, err := os.CreateTemp("", "")
|
|
require.NoError(t, err)
|
|
t.Cleanup(func() {
|
|
err := os.Remove(f.Name())
|
|
assert.NoError(t, err)
|
|
})
|
|
|
|
exists, err := Exists(f.Name())
|
|
require.NoError(t, err)
|
|
|
|
require.True(t, exists)
|
|
}
|
|
|
|
func TestExists_Dir(t *testing.T) {
|
|
f := t.TempDir()
|
|
|
|
exists, err := Exists(f)
|
|
|
|
require.NoError(t, err)
|
|
require.True(t, exists)
|
|
}
|