Files
go-config/internal/structconv/structconv_test.go
T
eSliderandCursor c575341178 feat(go-config): multi-format codecs, envc CLI, fixtures, ASRs
- Module github.com/eslider/go-config with env/yaml/json/ini packages
- internal: source, keymap, merge, structconv, bytesutil
- cmd/envc: convert, get, merge
- docs/asr ASR-0001..0008, README/CHANGELOG/AGENTS refresh
- golangci-lint v2 config; tests + fixtures

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-02 14:04:01 +01:00

29 lines
522 B
Go

package structconv
import (
"fmt"
"testing"
)
func TestDecodeEncodeRoundTrip(t *testing.T) {
type nested struct {
V int `mapstructure:"v"`
}
type root struct {
A nested `mapstructure:"a"`
}
in := map[string]any{"a": map[string]any{"v": 7}}
var dst root
if err := Decode(in, &dst, Options{WeaklyTyped: true, Trim: true}); err != nil {
t.Fatal(err)
}
out, err := Encode(&dst)
if err != nil {
t.Fatal(err)
}
am := out["a"].(map[string]any)
if fmt.Sprint(am["v"]) != "7" {
t.Fatalf("%#v", out)
}
}