spf13--viper/finder_test.go
Mark Sagi-Kazar f452b09dd9 feat: add finder
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2024-06-04 13:39:13 +02:00

42 lines
679 B
Go

package viper
import (
"testing"
"github.com/spf13/afero"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
type finderStub struct {
results []string
}
func (f finderStub) Find(_ afero.Fs) ([]string, error) {
return f.results, nil
}
func TestFinders(t *testing.T) {
finder := Finders(
finderStub{
results: []string{
"/home/user/.viper.yaml",
},
},
finderStub{
results: []string{
"/etc/viper/config.yaml",
},
},
)
results, err := finder.Find(afero.NewMemMapFs())
require.NoError(t, err)
expected := []string{
"/home/user/.viper.yaml",
"/etc/viper/config.yaml",
}
assert.Equal(t, expected, results)
}