mirror of
https://github.com/foomo/sesamy-go.git
synced 2025-10-16 12:35:43 +00:00
38 lines
656 B
Go
38 lines
656 B
Go
package sesamy_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/foomo/sesamy-go/pkg/sesamy"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestDecodeParams(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
type params struct {
|
|
Title string `json:"title"`
|
|
}
|
|
|
|
event := sesamy.Event[any]{
|
|
Name: "test",
|
|
Params: map[string]any{
|
|
"title": "foo",
|
|
"description": "foo",
|
|
},
|
|
}
|
|
|
|
var p params
|
|
require.NoError(t, event.DecodeParams(&p))
|
|
assert.Equal(t, "foo", p.Title)
|
|
|
|
p.Title = "bar"
|
|
|
|
require.NoError(t, event.EncodeParams(p))
|
|
assert.Equal(t, map[string]any{
|
|
"title": "bar",
|
|
"description": "foo",
|
|
}, event.Params)
|
|
}
|