1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-05-19 21:23:04 +02:00

49 lines
755 B
Go
Raw Normal View History

2020-12-26 15:32:45 +00:00
package cue
import (
"testing"
"github.com/stretchr/testify/assert"
)
func Test_cueEncoder_Decode(t *testing.T) {
type Cfg struct {
Msg string
Place string
}
var vv Cfg
type args struct {
d []byte
v interface{}
}
tests := []struct {
name string
c cueEncoder
args args
wantErr bool
}{
{
name: "test place holder",
c: cueEncoder{},
args: args{
d: []byte(`
msg: "Hello \(place)!"
place: string | *"world" // "world" is the default.
`),
v: &vv,
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
err := tt.c.Decode(tt.args.d, tt.args.v)
assert.NoError(t, err)
assert := assert.New(t)
assert.Equal(vv.Msg, "Hello world!")
})
}
}