mirror of
https://github.com/go-ini/ini.git
synced 2026-06-19 21:46:45 +02:00
data_source: support io.Reader
This commit is contained in:
@@ -6,7 +6,7 @@ test:
|
||||
go test -v -cover -race
|
||||
|
||||
bench:
|
||||
go test -v -cover -race -test.bench=. -test.benchmem
|
||||
go test -v -cover -test.bench=. -test.benchmem
|
||||
|
||||
vet:
|
||||
go vet
|
||||
|
||||
@@ -66,6 +66,8 @@ func parseDataSource(source interface{}) (dataSource, error) {
|
||||
return sourceFile{s}, nil
|
||||
case []byte:
|
||||
return &sourceData{s}, nil
|
||||
case io.Reader:
|
||||
return &sourceReadCloser{ioutil.NopCloser(s)}, nil
|
||||
case io.ReadCloser:
|
||||
return &sourceReadCloser{s}, nil
|
||||
default:
|
||||
|
||||
+4
-8
@@ -52,15 +52,11 @@ var update = flag.Bool("update", false, "Update .golden files")
|
||||
|
||||
func TestLoad(t *testing.T) {
|
||||
Convey("Load from good data sources", t, func() {
|
||||
f, err := ini.Load([]byte(`
|
||||
NAME = ini
|
||||
VERSION = v1
|
||||
IMPORT_PATH = gopkg.in/%(NAME)s.%(VERSION)s`),
|
||||
f, err := ini.Load(
|
||||
"testdata/minimal.ini",
|
||||
ioutil.NopCloser(bytes.NewReader([]byte(`
|
||||
[author]
|
||||
NAME = Unknwon
|
||||
`))),
|
||||
[]byte("NAME = ini\nIMPORT_PATH = gopkg.in/%(NAME)s.%(VERSION)s"),
|
||||
bytes.NewReader([]byte(`VERSION = v1`)),
|
||||
ioutil.NopCloser(bytes.NewReader([]byte("[author]\nNAME = Unknwon"))),
|
||||
)
|
||||
So(err, ShouldBeNil)
|
||||
So(f, ShouldNotBeNil)
|
||||
|
||||
Reference in New Issue
Block a user