mirror of
https://github.com/spf13/viper
synced 2024-11-14 00:57:01 +00:00
43 lines
679 B
Go
43 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)
|
||
|
}
|