github.com/yandex/pandora@v0.5.32/lib/testutil/afero.go (about) 1 package testutil 2 3 import ( 4 "io" 5 "io/ioutil" 6 7 "github.com/spf13/afero" 8 "github.com/stretchr/testify/assert" 9 "github.com/stretchr/testify/require" 10 ) 11 12 func ReadString(t TestingT, r io.Reader) string { 13 data, err := ioutil.ReadAll(r) 14 require.NoError(t, err) 15 return string(data) 16 } 17 18 func ReadFileString(t TestingT, fs afero.Fs, name string) string { 19 getHelper(t).Helper() 20 data, err := afero.ReadFile(fs, name) 21 require.NoError(t, err) 22 return string(data) 23 24 } 25 26 func AssertFileEqual(t TestingT, fs afero.Fs, name string, expected string) { 27 getHelper(t).Helper() 28 actual := ReadFileString(t, fs, name) 29 assert.Equal(t, expected, actual) 30 }