github.com/Asutorufa/yuhaiin@v0.3.6-0.20240502055049-7984da7023a0/pkg/components/config/setting_test.go (about)

     1  package config
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/Asutorufa/yuhaiin/pkg/protos/config"
     7  	"github.com/Asutorufa/yuhaiin/pkg/protos/config/dns"
     8  	"github.com/Asutorufa/yuhaiin/pkg/utils/assert"
     9  	"github.com/Asutorufa/yuhaiin/pkg/utils/jsondb"
    10  	"google.golang.org/protobuf/encoding/protojson"
    11  )
    12  
    13  func TestMergeDefault(t *testing.T) {
    14  	src := &config.Setting{
    15  		Ipv6: false,
    16  		Dns: &dns.DnsConfig{
    17  			Remote: &dns.Dns{
    18  				Host:          "xxxx",
    19  				Type:          dns.Type_udp,
    20  				Subnet:        "",
    21  				TlsServername: "",
    22  			},
    23  		},
    24  	}
    25  
    26  	jsondb.MergeDefault(src.ProtoReflect(), defaultSetting("").ProtoReflect())
    27  
    28  	data, err := protojson.MarshalOptions{Indent: "\t"}.Marshal(src)
    29  	assert.NoError(t, err)
    30  
    31  	t.Log(string(data))
    32  }