milvus/pkg/config/file_source_test.go
congqixia 0645d46ec6
fix: Skip EOF error when default empty yaml file (#37445)
Related to #37404

---------

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
2024-11-05 19:26:24 +08:00

33 lines
534 B
Go

package config
import (
"os"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestEmptyYaml(t *testing.T) {
file, err := os.CreateTemp(os.TempDir(), "milvus_ut_config_fs_*.yaml")
require.NoError(t, err)
filepath := file.Name()
file.WriteString("#")
file.Close()
defer os.Remove(filepath)
fs := NewFileSource(&FileInfo{
Files: []string{filepath},
RefreshInterval: time.Hour,
})
_, err = fs.GetConfigurations()
assert.NoError(t, err)
fs.Close()
}