1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
//go:build go1.16
// +build go1.16
package toml
import (
"fmt"
"testing"
"testing/fstest"
)
func TestDecodeFS(t *testing.T) {
fsys := fstest.MapFS{
"test.toml": &fstest.MapFile{
Data: []byte("a = 42"),
},
}
var i struct{ A int }
meta, err := DecodeFS(fsys, "test.toml", &i)
if err != nil {
t.Fatal(err)
}
have := fmt.Sprintf("%v %v %v", i, meta.Keys(), meta.Type("a"))
want := "{42} [a] Integer"
if have != want {
t.Errorf("\nhave: %s\nwant: %s", have, want)
}
}
|