Files
dify-plugin-daemon/pkg/utils/parser/struct2map_test.go
2025-11-17 15:58:50 +08:00

35 lines
351 B
Go

package parser
import (
"testing"
)
func TestStruct2Map(t *testing.T) {
type Base struct {
A int `json:"a"`
}
type p struct {
Base
B int `json:"b"`
}
d := p{
Base: Base{
A: 1,
},
B: 2,
}
result := StructToMap(d)
if result["a"] != 1 {
t.Error("a should be 1")
}
if result["b"] != 2 {
t.Error("b should be 2")
}
}