-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmarshal_test.go
68 lines (51 loc) · 1.47 KB
/
marshal_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package marshaler
import (
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"testing"
)
type marshalTestSuite struct {
suite.Suite
}
func TestMarshaler(t *testing.T) {
suite.Run(t, new(marshalTestSuite))
}
func (s *marshalTestSuite) r() *require.Assertions {
return s.Require()
}
func (t *marshalTestSuite) TestMarshalStrings() {
type test struct {
command struct{} `v8:"/command"`
Str string `v8:"-str"`
StrOpt string `v8:"-strOpt, optional"`
}
object := test{}
object.Str = "TesString"
object.StrOpt = "TesOptString"
values, err := Marshal(object)
t.r().NoError(err)
t.r().Equal(values[0], "/command", "must be equal")
t.r().Equal(values[1], "-str "+object.Str, "must be equal")
t.r().Equal(values[2], "-strOpt "+object.StrOpt, "must be equal")
//t.r().Equal(codes[0].PromocodeID, "START", "Промокод должен быть START")
}
func (t *marshalTestSuite) TestMarshalInnerStructs() {
type inner struct {
S string `v8:"/S"`
}
type test struct {
S inner `v8:",inherit"`
Str string `v8:"-str"`
StrOpt string `v8:"-strOpt, optional"`
}
object := test{S: inner{
"testing",
}}
object.Str = "TesString"
object.StrOpt = "TesOptString"
values, err := Marshal(object)
t.r().NoError(err)
t.r().Equal(values[0], "/S "+"testing", "must be equal")
t.r().Equal(values[1], "-str "+object.Str, "must be equal")
//t.r().Equal(codes[0].PromocodeID, "START", "Промокод должен быть START")
}