-
Notifications
You must be signed in to change notification settings - Fork 12
/
pcopy_enum_fix2_test.go
83 lines (72 loc) · 2.58 KB
/
pcopy_enum_fix2_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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Copyright [2020-2023] [guonaihong]
package pcopy
import (
"testing"
"github.com/stretchr/testify/assert"
)
type DiaryResourceTypeDst int32
const (
// 文本
DiaryResourceType_DiaryResourceTypeTextDst DiaryResourceTypeDst = 0
// 图片
DiaryResourceType_DiaryResourceTypeImageDst DiaryResourceTypeDst = 1
// 视频
DiaryResourceType_DiaryResourceTypeVideoDst DiaryResourceTypeDst = 2
// Ours类型
DiaryResourceType_DiaryResourceTypeOursDst DiaryResourceTypeDst = 3
)
type SquareDiaryItemDst struct {
// 资源类型
ResourceType DiaryResourceTypeDst `protobuf:"varint,7,opt,name=ResourceType,proto3,enum=topic.v1.DiaryResourceType" json:"ResourceType,omitempty"`
// 资源链接数组
}
type GetRecommendedListResp_GetRecommendedListRespData struct {
// 列表
List []*SquareDiaryItemDst `protobuf:"bytes,1,rep,name=List,proto3" json:"List,omitempty"`
// 是否有更多记录
HasMore bool `protobuf:"varint,2,opt,name=HasMore,proto3" json:"HasMore,omitempty"`
// 记录位置
Pos int32 `protobuf:"varint,3,opt,name=Pos,proto3" json:"Pos,omitempty"`
// 相同记录的偏移量
Offset int32 `protobuf:"varint,4,opt,name=Offset,proto3" json:"Offset,omitempty"`
}
type DiaryResourceTypeSrc int32
const (
// 文本
DiaryResourceType_DiaryResourceTypeText DiaryResourceTypeSrc = 0
// 图片
DiaryResourceType_DiaryResourceTypeImage DiaryResourceTypeSrc = 1
// 视频
DiaryResourceType_DiaryResourceTypeVideo DiaryResourceTypeSrc = 2
// Ours类型
DiaryResourceType_DiaryResourceTypeOurs DiaryResourceTypeSrc = 3
)
type SquareDiaryItemSrc struct {
// 资源类型
ResourceType DiaryResourceTypeSrc `protobuf:"varint,7,opt,name=ResourceType,proto3,enum=topic.v1.DiaryResourceType" json:"ResourceType,omitempty"`
// 资源链接数组
}
type GetRecommendedListResp struct {
// 列表
List []*SquareDiaryItemSrc `protobuf:"bytes,1,rep,name=List,proto3" json:"List,omitempty"`
// 是否有更多记录
HasMore bool `protobuf:"varint,2,opt,name=HasMore,proto3" json:"HasMore,omitempty"`
// 记录位置
Pos int32 `protobuf:"varint,3,opt,name=Pos,proto3" json:"Pos,omitempty"`
// 相同记录的偏移量
Offset int32 `protobuf:"varint,4,opt,name=Offset,proto3" json:"Offset,omitempty"`
}
func Test_Fix2(t *testing.T) {
var r *GetRecommendedListResp_GetRecommendedListRespData
resp := GetRecommendedListResp{
// 帮我优化这个代码
List: []*SquareDiaryItemSrc{{ResourceType: DiaryResourceType_DiaryResourceTypeVideo}},
HasMore: true,
Pos: 10,
Offset: 11,
}
err := Copy(&r, &resp)
assert.NoError(t, err)
assert.NotEqual(t, r, nil)
assert.NotEqual(t, len(r.List), 0)
}