mirror of
https://github.com/spf13/viper
synced 2024-11-04 20:27:02 +00:00
f452b09dd9
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
42 lines
679 B
Go
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)
|
|
}
|