yaml_test.go 480 B

123456789101112131415161718192021
  1. // Copyright 2019 Gin Core Team. All rights reserved.
  2. // Use of this source code is governed by a MIT style
  3. // license that can be found in the LICENSE file.
  4. package binding
  5. import (
  6. "testing"
  7. "github.com/stretchr/testify/assert"
  8. "github.com/stretchr/testify/require"
  9. )
  10. func TestYAMLBindingBindBody(t *testing.T) {
  11. var s struct {
  12. Foo string `yaml:"foo"`
  13. }
  14. err := yamlBinding{}.BindBody([]byte("foo: FOO"), &s)
  15. require.NoError(t, err)
  16. assert.Equal(t, "FOO", s.Foo)
  17. }