-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtype_test.go
More file actions
84 lines (67 loc) · 1.76 KB
/
type_test.go
File metadata and controls
84 lines (67 loc) · 1.76 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package raiden_test
import (
"encoding/json"
"testing"
"github.com/sev-2/raiden"
"github.com/stretchr/testify/assert"
)
const (
DefaultTypeSchema = "public"
)
func TestTypeBase_Name(t *testing.T) {
typeBase := raiden.TypeBase{}
assert.Equal(t, "", typeBase.Name())
}
func TestTypeBase_Schema(t *testing.T) {
typeBase := raiden.TypeBase{}
assert.Equal(t, raiden.DefaultTypeSchema, typeBase.Schema())
}
func TestTypeBase_Format(t *testing.T) {
typeBase := raiden.TypeBase{}
assert.Equal(t, "", typeBase.Format())
}
func TestTypeBase_Enums(t *testing.T) {
typeBase := raiden.TypeBase{}
assert.Equal(t, 0, len(typeBase.Enums()))
}
func TestTypeBase_Attribute(t *testing.T) {
typeBase := raiden.TypeBase{}
assert.Equal(t, 0, len(typeBase.Attributes()))
}
func TestTypeBase_Comment(t *testing.T) {
typeBase := raiden.TypeBase{}
var expected *string
assert.EqualValues(t, expected, typeBase.Comment())
}
func TestTypeBase_Value(t *testing.T) {
typeBase := raiden.TypeBase{
Value: "test",
}
assert.Equal(t, "test", typeBase.String())
}
func TestTypeBase_SetValue(t *testing.T) {
typeBase := raiden.TypeBase{}
typeBase.SetValue("test")
assert.Equal(t, "test", typeBase.String())
}
type MockType struct {
Type raiden.TypeBase `json:"mock_type"`
}
func TestTypeBase_JsonUnmarshal(t *testing.T) {
jsonStr := "{\"mock_type\": \"test_type\"}"
var mockType MockType
err := json.Unmarshal([]byte(jsonStr), &mockType)
assert.NoError(t, err)
assert.Equal(t, "test_type", mockType.Type.Value)
}
func TestTypeBase_JsonMarshall(t *testing.T) {
jsonStr := "{\"mock_type\":\"test_type\"}"
mockType := MockType{
Type: raiden.TypeBase{
Value: "test_type",
},
}
byteData, err := json.Marshal(&mockType)
assert.NoError(t, err)
assert.Equal(t, jsonStr, string(byteData))
}