git.sr.ht/~pingoo/stdx@v0.0.0-20240218134121-094174641f6e/toml/decode_go116_test.go (about)

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