♻️ Replace *common.Fields with value embedding
This commit is contained in:
1 parent
5086a87edb
commit
d897e3c159
47 files changed
+187
-203
No files matched your search
@@ -17,7 +17,7 @@ var (
|
||||
)
|
||||
|
||||
type Activity struct {
|
||||
*common.Fields
|
||||
common.Fields
|
||||
Home *bool `yaml:"home" json:"home,omitempty"`
|
||||
Mine *bool `yaml:"mine" json:"mine,omitempty"`
|
||||
PublishedAfter string `yaml:"published_after" json:"published_after,omitempty"`
|
||||
@@ -33,7 +33,7 @@ type IActivity[T any] interface {
|
||||
type Option func(*Activity)
|
||||
|
||||
func NewActivity(opts ...Option) IActivity[youtube.Activity] {
|
||||
a := &Activity{Fields: &common.Fields{}}
|
||||
a := &Activity{Fields: common.Fields{}}
|
||||
for _, opt := range opts {
|
||||
opt(a)
|
||||
}
|
||||
@@ -70,7 +70,7 @@ func (a *Activity) Get() ([]*youtube.Activity, error) {
|
||||
}
|
||||
|
||||
return common.Paginate(
|
||||
a.Fields, call,
|
||||
&a.Fields, call,
|
||||
func(r *youtube.ActivityListResponse) ([]*youtube.Activity, string) {
|
||||
return r.Items, r.NextPageToken
|
||||
}, errGetActivity,
|
||||
|
||||
@@ -45,7 +45,7 @@ func TestNewActivity(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Activity{
|
||||
Fields: &common.Fields{
|
||||
Fields: common.Fields{
|
||||
Service: svc,
|
||||
ChannelId: "test-channel-123",
|
||||
MaxResults: 50,
|
||||
@@ -62,7 +62,7 @@ func TestNewActivity(t *testing.T) {
|
||||
args: args{
|
||||
opts: []Option{},
|
||||
},
|
||||
want: &Activity{Fields: &common.Fields{}},
|
||||
want: &Activity{Fields: common.Fields{}},
|
||||
},
|
||||
{
|
||||
name: "with nil boolean options",
|
||||
@@ -72,7 +72,7 @@ func TestNewActivity(t *testing.T) {
|
||||
WithMine(nil),
|
||||
},
|
||||
},
|
||||
want: &Activity{Fields: &common.Fields{}},
|
||||
want: &Activity{Fields: common.Fields{}},
|
||||
},
|
||||
{
|
||||
name: "with false boolean options",
|
||||
@@ -83,7 +83,7 @@ func TestNewActivity(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Activity{
|
||||
Fields: &common.Fields{},
|
||||
Fields: common.Fields{},
|
||||
Home: &homeFalse,
|
||||
Mine: &mineFalse,
|
||||
},
|
||||
@@ -96,7 +96,7 @@ func TestNewActivity(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Activity{
|
||||
Fields: &common.Fields{MaxResults: math.MaxInt64},
|
||||
Fields: common.Fields{MaxResults: math.MaxInt64},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -107,7 +107,7 @@ func TestNewActivity(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Activity{
|
||||
Fields: &common.Fields{MaxResults: 1},
|
||||
Fields: common.Fields{MaxResults: 1},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -121,7 +121,7 @@ func TestNewActivity(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Activity{
|
||||
Fields: &common.Fields{ChannelId: ""},
|
||||
Fields: common.Fields{ChannelId: ""},
|
||||
PublishedAfter: "",
|
||||
PublishedBefore: "",
|
||||
RegionCode: "",
|
||||
@@ -137,7 +137,7 @@ func TestNewActivity(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Activity{
|
||||
Fields: &common.Fields{
|
||||
Fields: common.Fields{
|
||||
ChannelId: "partial-channel",
|
||||
MaxResults: 25,
|
||||
},
|
||||
|
||||
@@ -24,7 +24,7 @@ var (
|
||||
)
|
||||
|
||||
type Caption struct {
|
||||
*common.Fields
|
||||
common.Fields
|
||||
File string `yaml:"file" json:"file,omitempty"`
|
||||
AudioTrackType string `yaml:"audio_track_type" json:"audio_track_type,omitempty"`
|
||||
IsAutoSynced *bool `yaml:"is_auto_synced" json:"is_auto_synced,omitempty"`
|
||||
@@ -53,16 +53,13 @@ type ICaption[T youtube.Caption] interface {
|
||||
type Option func(*Caption)
|
||||
|
||||
func NewCaption(opts ...Option) ICaption[youtube.Caption] {
|
||||
c := &Caption{Fields: &common.Fields{}}
|
||||
c := &Caption{Fields: common.Fields{}}
|
||||
for _, opt := range opts {
|
||||
opt(c)
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
||||
func (c *Caption) GetFields() *common.Fields {
|
||||
return c.Fields
|
||||
}
|
||||
|
||||
func (c *Caption) Get() ([]*youtube.Caption, error) {
|
||||
if err := c.EnsureService(); err != nil {
|
||||
|
||||
@@ -73,7 +73,7 @@ func TestNewCaption(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Caption{
|
||||
Fields: &common.Fields{
|
||||
Fields: common.Fields{
|
||||
Service: svc,
|
||||
Ids: []string{"caption1", "caption2"},
|
||||
OnBehalfOfContentOwner: "owner123",
|
||||
@@ -99,7 +99,7 @@ func TestNewCaption(t *testing.T) {
|
||||
args: args{
|
||||
opts: []Option{},
|
||||
},
|
||||
want: &Caption{Fields: &common.Fields{}},
|
||||
want: &Caption{Fields: common.Fields{}},
|
||||
},
|
||||
{
|
||||
name: "with nil boolean options",
|
||||
@@ -112,7 +112,7 @@ func TestNewCaption(t *testing.T) {
|
||||
WithIsLarge(nil),
|
||||
},
|
||||
},
|
||||
want: &Caption{Fields: &common.Fields{}},
|
||||
want: &Caption{Fields: common.Fields{}},
|
||||
},
|
||||
{
|
||||
name: "with false boolean options",
|
||||
@@ -126,7 +126,7 @@ func TestNewCaption(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Caption{
|
||||
Fields: &common.Fields{},
|
||||
Fields: common.Fields{},
|
||||
IsAutoSynced: &isAutoSyncedFalse,
|
||||
IsCC: &isCCFalse,
|
||||
IsDraft: &isDraftFalse,
|
||||
@@ -151,7 +151,7 @@ func TestNewCaption(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Caption{
|
||||
Fields: &common.Fields{
|
||||
Fields: common.Fields{
|
||||
OnBehalfOfContentOwner: "",
|
||||
},
|
||||
File: "",
|
||||
@@ -176,7 +176,7 @@ func TestNewCaption(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Caption{
|
||||
Fields: &common.Fields{Ids: []string{"caption1"}},
|
||||
Fields: common.Fields{Ids: []string{"caption1"}},
|
||||
Language: "fr",
|
||||
VideoId: "video456",
|
||||
IsCC: &isCCTrue,
|
||||
|
||||
@@ -19,7 +19,7 @@ var (
|
||||
)
|
||||
|
||||
type Channel struct {
|
||||
*common.Fields
|
||||
common.Fields
|
||||
CategoryId string `yaml:"category_id" json:"category_id,omitempty"`
|
||||
ForHandle string `yaml:"for_handle" json:"for_handle,omitempty"`
|
||||
ForUsername string `yaml:"for_username" json:"for_username,omitempty"`
|
||||
@@ -42,7 +42,7 @@ type IChannel[T youtube.Channel] interface {
|
||||
type Option func(*Channel)
|
||||
|
||||
func NewChannel(opts ...Option) IChannel[youtube.Channel] {
|
||||
c := &Channel{Fields: &common.Fields{}}
|
||||
c := &Channel{Fields: common.Fields{}}
|
||||
for _, opt := range opts {
|
||||
opt(c)
|
||||
}
|
||||
@@ -83,7 +83,7 @@ func (c *Channel) Get() ([]*youtube.Channel, error) {
|
||||
}
|
||||
|
||||
return common.Paginate(
|
||||
c.Fields, call,
|
||||
&c.Fields, call,
|
||||
func(r *youtube.ChannelListResponse) ([]*youtube.Channel, string) {
|
||||
return r.Items, r.NextPageToken
|
||||
}, errGetChannel,
|
||||
|
||||
@@ -58,7 +58,7 @@ func TestNewChannel(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Channel{
|
||||
Fields: &common.Fields{
|
||||
Fields: common.Fields{
|
||||
Service: svc,
|
||||
Parts: []string{"snippet", "contentDetails"},
|
||||
Output: "json",
|
||||
@@ -88,7 +88,7 @@ func TestNewChannel(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Channel{
|
||||
Fields: &common.Fields{Service: svc},
|
||||
Fields: common.Fields{Service: svc},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -102,7 +102,7 @@ func TestNewChannel(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Channel{
|
||||
Fields: &common.Fields{Service: svc},
|
||||
Fields: common.Fields{Service: svc},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -116,7 +116,7 @@ func TestNewChannel(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Channel{
|
||||
Fields: &common.Fields{Service: svc},
|
||||
Fields: common.Fields{Service: svc},
|
||||
ManagedByMe: &managedByMeFalse,
|
||||
Mine: &mineFalse,
|
||||
MySubscribers: &mySubscribersFalse,
|
||||
@@ -131,7 +131,7 @@ func TestNewChannel(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Channel{
|
||||
Fields: &common.Fields{Service: svc, MaxResults: math.MaxInt64},
|
||||
Fields: common.Fields{Service: svc, MaxResults: math.MaxInt64},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -143,7 +143,7 @@ func TestNewChannel(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Channel{
|
||||
Fields: &common.Fields{Service: svc, MaxResults: 1},
|
||||
Fields: common.Fields{Service: svc, MaxResults: 1},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -164,7 +164,7 @@ func TestNewChannel(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Channel{
|
||||
Fields: &common.Fields{Service: svc},
|
||||
Fields: common.Fields{Service: svc},
|
||||
CategoryId: "",
|
||||
ForHandle: "",
|
||||
ForUsername: "",
|
||||
@@ -187,7 +187,7 @@ func TestNewChannel(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Channel{
|
||||
Fields: &common.Fields{Service: svc, Ids: []string{"channel1"}, MaxResults: 50},
|
||||
Fields: common.Fields{Service: svc, Ids: []string{"channel1"}, MaxResults: 50},
|
||||
Title: "My Channel",
|
||||
Country: "UK",
|
||||
},
|
||||
|
||||
@@ -18,7 +18,7 @@ var (
|
||||
)
|
||||
|
||||
type ChannelBanner struct {
|
||||
*common.Fields
|
||||
common.Fields
|
||||
File string `yaml:"file" json:"file,omitempty"`
|
||||
|
||||
OnBehalfOfContentOwnerChannel string `yaml:"on_behalf_of_content_owner_channel" json:"on_behalf_of_content_owner_channel,omitempty"`
|
||||
@@ -31,7 +31,7 @@ type IChannelBanner interface {
|
||||
type Option func(banner *ChannelBanner)
|
||||
|
||||
func NewChannelBanner(opts ...Option) IChannelBanner {
|
||||
cb := &ChannelBanner{Fields: &common.Fields{}}
|
||||
cb := &ChannelBanner{Fields: common.Fields{}}
|
||||
for _, opt := range opts {
|
||||
opt(cb)
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ func TestNewChannelBanner(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &ChannelBanner{
|
||||
Fields: &common.Fields{
|
||||
Fields: common.Fields{
|
||||
Output: "json",
|
||||
Service: svc,
|
||||
ChannelId: "channel123",
|
||||
@@ -171,7 +171,7 @@ func TestNewChannelBanner(t *testing.T) {
|
||||
args: args{
|
||||
opts: []Option{},
|
||||
},
|
||||
want: &ChannelBanner{Fields: &common.Fields{}},
|
||||
want: &ChannelBanner{Fields: common.Fields{}},
|
||||
},
|
||||
{
|
||||
name: "with empty string values",
|
||||
@@ -185,7 +185,7 @@ func TestNewChannelBanner(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &ChannelBanner{
|
||||
Fields: &common.Fields{
|
||||
Fields: common.Fields{
|
||||
Output: "",
|
||||
ChannelId: "",
|
||||
OnBehalfOfContentOwner: "",
|
||||
@@ -204,7 +204,7 @@ func TestNewChannelBanner(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &ChannelBanner{
|
||||
Fields: &common.Fields{
|
||||
Fields: common.Fields{
|
||||
Output: "yaml",
|
||||
ChannelId: "partialChannel",
|
||||
},
|
||||
|
||||
@@ -19,7 +19,7 @@ var (
|
||||
)
|
||||
|
||||
type ChannelSection struct {
|
||||
*common.Fields
|
||||
common.Fields
|
||||
Mine *bool `yaml:"mine" json:"mine,omitempty"`
|
||||
}
|
||||
|
||||
@@ -34,16 +34,13 @@ type IChannelSection[T any] interface {
|
||||
type Option func(*ChannelSection)
|
||||
|
||||
func NewChannelSection(opts ...Option) IChannelSection[youtube.ChannelSection] {
|
||||
cs := &ChannelSection{Fields: &common.Fields{}}
|
||||
cs := &ChannelSection{Fields: common.Fields{}}
|
||||
for _, opt := range opts {
|
||||
opt(cs)
|
||||
}
|
||||
return cs
|
||||
}
|
||||
|
||||
func (cs *ChannelSection) GetFields() *common.Fields {
|
||||
return cs.Fields
|
||||
}
|
||||
|
||||
func (cs *ChannelSection) Get() (
|
||||
[]*youtube.ChannelSection, error,
|
||||
|
||||
@@ -41,7 +41,7 @@ func TestNewChannelSection(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &ChannelSection{
|
||||
Fields: &common.Fields{
|
||||
Fields: common.Fields{
|
||||
Service: svc,
|
||||
Ids: []string{"section1", "section2"},
|
||||
ChannelId: "channel123",
|
||||
@@ -56,7 +56,7 @@ func TestNewChannelSection(t *testing.T) {
|
||||
args: args{
|
||||
opts: []Option{},
|
||||
},
|
||||
want: &ChannelSection{Fields: &common.Fields{}},
|
||||
want: &ChannelSection{Fields: common.Fields{}},
|
||||
},
|
||||
{
|
||||
name: "with nil boolean options",
|
||||
@@ -65,7 +65,7 @@ func TestNewChannelSection(t *testing.T) {
|
||||
WithMine(nil),
|
||||
},
|
||||
},
|
||||
want: &ChannelSection{Fields: &common.Fields{}},
|
||||
want: &ChannelSection{Fields: common.Fields{}},
|
||||
},
|
||||
{
|
||||
name: "with false boolean options",
|
||||
@@ -75,7 +75,7 @@ func TestNewChannelSection(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &ChannelSection{
|
||||
Fields: &common.Fields{},
|
||||
Fields: common.Fields{},
|
||||
Mine: &mineFalse,
|
||||
},
|
||||
},
|
||||
@@ -89,7 +89,7 @@ func TestNewChannelSection(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &ChannelSection{
|
||||
Fields: &common.Fields{
|
||||
Fields: common.Fields{
|
||||
ChannelId: "",
|
||||
Hl: "",
|
||||
OnBehalfOfContentOwner: "",
|
||||
@@ -106,7 +106,7 @@ func TestNewChannelSection(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &ChannelSection{
|
||||
Fields: &common.Fields{
|
||||
Fields: common.Fields{
|
||||
Ids: []string{"section1"},
|
||||
ChannelId: "partialChannel",
|
||||
Hl: "fr",
|
||||
|
||||
@@ -23,7 +23,7 @@ var (
|
||||
)
|
||||
|
||||
type Comment struct {
|
||||
*common.Fields
|
||||
common.Fields
|
||||
AuthorChannelId string `yaml:"author_channel_id" json:"author_channel_id,omitempty"`
|
||||
CanRate *bool `yaml:"can_rate" json:"can_rate,omitempty"`
|
||||
ParentId string `yaml:"parent_id" json:"parent_id,omitempty"`
|
||||
@@ -48,7 +48,7 @@ type IComment[T any] interface {
|
||||
type Option func(*Comment)
|
||||
|
||||
func NewComment(opts ...Option) IComment[youtube.Comment] {
|
||||
c := &Comment{Fields: &common.Fields{}}
|
||||
c := &Comment{Fields: common.Fields{}}
|
||||
for _, opt := range opts {
|
||||
opt(c)
|
||||
}
|
||||
@@ -71,7 +71,7 @@ func (c *Comment) Get() ([]*youtube.Comment, error) {
|
||||
}
|
||||
|
||||
return common.Paginate(
|
||||
c.Fields, call,
|
||||
&c.Fields, call,
|
||||
func(r *youtube.CommentListResponse) ([]*youtube.Comment, string) {
|
||||
return r.Items, r.NextPageToken
|
||||
}, errGetComment,
|
||||
|
||||
@@ -53,7 +53,7 @@ func TestNewComment(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Comment{
|
||||
Fields: &common.Fields{
|
||||
Fields: common.Fields{
|
||||
Service: svc,
|
||||
Parts: []string{"id", "snippet"},
|
||||
Output: "json",
|
||||
@@ -77,7 +77,7 @@ func TestNewComment(t *testing.T) {
|
||||
args: args{
|
||||
opts: []Option{},
|
||||
},
|
||||
want: &Comment{Fields: &common.Fields{}},
|
||||
want: &Comment{Fields: common.Fields{}},
|
||||
},
|
||||
{
|
||||
name: "with nil boolean options",
|
||||
@@ -87,7 +87,7 @@ func TestNewComment(t *testing.T) {
|
||||
WithBanAuthor(nil),
|
||||
},
|
||||
},
|
||||
want: &Comment{Fields: &common.Fields{}},
|
||||
want: &Comment{Fields: common.Fields{}},
|
||||
},
|
||||
{
|
||||
name: "with false boolean options",
|
||||
@@ -98,7 +98,7 @@ func TestNewComment(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Comment{
|
||||
Fields: &common.Fields{},
|
||||
Fields: common.Fields{},
|
||||
CanRate: &canRateFalse,
|
||||
BanAuthor: &banAuthorFalse,
|
||||
},
|
||||
@@ -111,7 +111,7 @@ func TestNewComment(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Comment{
|
||||
Fields: &common.Fields{MaxResults: math.MaxInt64},
|
||||
Fields: common.Fields{MaxResults: math.MaxInt64},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -122,7 +122,7 @@ func TestNewComment(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Comment{
|
||||
Fields: &common.Fields{MaxResults: 1},
|
||||
Fields: common.Fields{MaxResults: 1},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -140,7 +140,7 @@ func TestNewComment(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Comment{
|
||||
Fields: &common.Fields{},
|
||||
Fields: common.Fields{},
|
||||
AuthorChannelId: "",
|
||||
ParentId: "",
|
||||
TextFormat: "",
|
||||
@@ -162,7 +162,7 @@ func TestNewComment(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Comment{
|
||||
Fields: &common.Fields{Service: svc, Ids: []string{"comment1"}, MaxResults: 25},
|
||||
Fields: common.Fields{Service: svc, Ids: []string{"comment1"}, MaxResults: 25},
|
||||
TextOriginal: "Partial comment",
|
||||
VideoId: "video456",
|
||||
},
|
||||
|
||||
@@ -18,7 +18,7 @@ var (
|
||||
)
|
||||
|
||||
type CommentThread struct {
|
||||
*common.Fields
|
||||
common.Fields
|
||||
AuthorChannelId string `yaml:"author_channel_id" json:"author_channel_id,omitempty"`
|
||||
ModerationStatus string `yaml:"moderation_status" json:"moderation_status,omitempty"`
|
||||
Order string `yaml:"order" json:"order,omitempty"`
|
||||
@@ -39,7 +39,7 @@ type ICommentThread[T any] interface {
|
||||
type Option func(*CommentThread)
|
||||
|
||||
func NewCommentThread(opts ...Option) ICommentThread[youtube.CommentThread] {
|
||||
c := &CommentThread{Fields: &common.Fields{}}
|
||||
c := &CommentThread{Fields: common.Fields{}}
|
||||
for _, opt := range opts {
|
||||
opt(c)
|
||||
}
|
||||
@@ -77,7 +77,7 @@ func (c *CommentThread) Get() ([]*youtube.CommentThread, error) {
|
||||
}
|
||||
|
||||
return common.Paginate(
|
||||
c.Fields, call,
|
||||
&c.Fields, call,
|
||||
func(r *youtube.CommentThreadListResponse) ([]*youtube.CommentThread, string) {
|
||||
return r.Items, r.NextPageToken
|
||||
}, errGetCommentThread,
|
||||
|
||||
@@ -47,7 +47,7 @@ func TestNewCommentThread(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &CommentThread{
|
||||
Fields: &common.Fields{
|
||||
Fields: common.Fields{
|
||||
Service: svc,
|
||||
Parts: []string{"id", "snippet"},
|
||||
Output: "json",
|
||||
@@ -70,7 +70,7 @@ func TestNewCommentThread(t *testing.T) {
|
||||
args: args{
|
||||
opts: []Option{},
|
||||
},
|
||||
want: &CommentThread{Fields: &common.Fields{}},
|
||||
want: &CommentThread{Fields: common.Fields{}},
|
||||
},
|
||||
{
|
||||
name: "with zero max results",
|
||||
@@ -80,7 +80,7 @@ func TestNewCommentThread(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &CommentThread{
|
||||
Fields: &common.Fields{MaxResults: math.MaxInt64},
|
||||
Fields: common.Fields{MaxResults: math.MaxInt64},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -91,7 +91,7 @@ func TestNewCommentThread(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &CommentThread{
|
||||
Fields: &common.Fields{MaxResults: 1},
|
||||
Fields: common.Fields{MaxResults: 1},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -112,7 +112,7 @@ func TestNewCommentThread(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &CommentThread{
|
||||
Fields: &common.Fields{
|
||||
Fields: common.Fields{
|
||||
Parts: nil,
|
||||
Output: "",
|
||||
ChannelId: "",
|
||||
@@ -139,7 +139,7 @@ func TestNewCommentThread(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &CommentThread{
|
||||
Fields: &common.Fields{
|
||||
Fields: common.Fields{
|
||||
Output: "yaml",
|
||||
Ids: []string{"thread1"},
|
||||
MaxResults: 50,
|
||||
|
||||
@@ -49,12 +49,10 @@ func (d *Fields) GetFields() *Fields {
|
||||
// SetContext implements the cobra-mcp ContextAware interface, enabling
|
||||
// automatic context injection from MCP tool handlers.
|
||||
func (d *Fields) SetContext(ctx context.Context) {
|
||||
if d != nil {
|
||||
d.Ctx = ctx
|
||||
if d.RedirectURL == "" {
|
||||
if url, ok := ctx.Value(redirectURLKey{}).(string); ok {
|
||||
d.RedirectURL = url
|
||||
}
|
||||
d.Ctx = ctx
|
||||
if d.RedirectURL == "" {
|
||||
if url, ok := ctx.Value(redirectURLKey{}).(string); ok {
|
||||
d.RedirectURL = url
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,10 +269,6 @@ func TestSetContext(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetContext_Nil(t *testing.T) {
|
||||
var f *Fields
|
||||
f.SetContext(context.Background()) // should not panic
|
||||
}
|
||||
|
||||
// ---------- TestEnsureService ----------
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ var (
|
||||
)
|
||||
|
||||
type I18nLanguage struct {
|
||||
*common.Fields
|
||||
common.Fields
|
||||
}
|
||||
|
||||
type II18nLanguage[T youtube.I18nLanguage] interface {
|
||||
@@ -28,7 +28,7 @@ type II18nLanguage[T youtube.I18nLanguage] interface {
|
||||
type Option func(*I18nLanguage)
|
||||
|
||||
func NewI18nLanguage(opts ...Option) II18nLanguage[youtube.I18nLanguage] {
|
||||
i := &I18nLanguage{Fields: &common.Fields{}}
|
||||
i := &I18nLanguage{Fields: common.Fields{}}
|
||||
for _, opt := range opts {
|
||||
opt(i)
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ func TestNewI18nLanguage(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &I18nLanguage{
|
||||
Fields: &common.Fields{
|
||||
Fields: common.Fields{
|
||||
Service: &youtube.Service{},
|
||||
Parts: []string{"snippet"},
|
||||
Output: "json",
|
||||
@@ -49,7 +49,7 @@ func TestNewI18nLanguage(t *testing.T) {
|
||||
args: args{
|
||||
opts: []Option{},
|
||||
},
|
||||
want: &I18nLanguage{Fields: &common.Fields{}},
|
||||
want: &I18nLanguage{Fields: common.Fields{}},
|
||||
},
|
||||
{
|
||||
name: "with empty string value",
|
||||
@@ -59,7 +59,7 @@ func TestNewI18nLanguage(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &I18nLanguage{
|
||||
Fields: &common.Fields{Hl: ""},
|
||||
Fields: common.Fields{Hl: ""},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ var (
|
||||
)
|
||||
|
||||
type I18nRegion struct {
|
||||
*common.Fields
|
||||
common.Fields
|
||||
}
|
||||
|
||||
type II18nRegion[T any] interface {
|
||||
@@ -28,7 +28,7 @@ type II18nRegion[T any] interface {
|
||||
type Option func(*I18nRegion)
|
||||
|
||||
func NewI18nRegion(opts ...Option) II18nRegion[youtube.I18nRegion] {
|
||||
i := &I18nRegion{Fields: &common.Fields{}}
|
||||
i := &I18nRegion{Fields: common.Fields{}}
|
||||
for _, opt := range opts {
|
||||
opt(i)
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ func TestNewI18nRegion(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &I18nRegion{
|
||||
Fields: &common.Fields{
|
||||
Fields: common.Fields{
|
||||
Service: svc,
|
||||
Parts: []string{"id", "snippet"},
|
||||
Output: "json",
|
||||
@@ -49,7 +49,7 @@ func TestNewI18nRegion(t *testing.T) {
|
||||
args: args{
|
||||
opts: []Option{},
|
||||
},
|
||||
want: &I18nRegion{Fields: &common.Fields{}},
|
||||
want: &I18nRegion{Fields: common.Fields{}},
|
||||
},
|
||||
{
|
||||
name: "with empty string value",
|
||||
@@ -59,7 +59,7 @@ func TestNewI18nRegion(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &I18nRegion{
|
||||
Fields: &common.Fields{Hl: ""},
|
||||
Fields: common.Fields{Hl: ""},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ var (
|
||||
)
|
||||
|
||||
type Member struct {
|
||||
*common.Fields
|
||||
common.Fields
|
||||
MemberChannelId string `yaml:"member_channel_id" json:"member_channel_id,omitempty"`
|
||||
HasAccessToLevel string `yaml:"has_access_to_level" json:"has_access_to_level,omitempty"`
|
||||
Mode string `yaml:"mode" json:"mode,omitempty"`
|
||||
@@ -31,7 +31,7 @@ type IMember[T any] interface {
|
||||
type Option func(*Member)
|
||||
|
||||
func NewMember(opts ...Option) IMember[youtube.Member] {
|
||||
m := &Member{Fields: &common.Fields{}}
|
||||
m := &Member{Fields: common.Fields{}}
|
||||
for _, opt := range opts {
|
||||
opt(m)
|
||||
}
|
||||
@@ -54,7 +54,7 @@ func (m *Member) Get() ([]*youtube.Member, error) {
|
||||
}
|
||||
|
||||
return common.Paginate(
|
||||
m.Fields, call,
|
||||
&m.Fields, call,
|
||||
func(r *youtube.MemberListResponse) ([]*youtube.Member, string) {
|
||||
return r.Items, r.NextPageToken
|
||||
}, errGetMember,
|
||||
|
||||
@@ -40,7 +40,7 @@ func TestNewMember(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Member{
|
||||
Fields: &common.Fields{
|
||||
Fields: common.Fields{
|
||||
Service: svc,
|
||||
Parts: []string{"snippet"},
|
||||
Output: "json",
|
||||
@@ -56,7 +56,7 @@ func TestNewMember(t *testing.T) {
|
||||
args: args{
|
||||
opts: []Option{},
|
||||
},
|
||||
want: &Member{Fields: &common.Fields{}},
|
||||
want: &Member{Fields: common.Fields{}},
|
||||
},
|
||||
{
|
||||
name: "with zero max results",
|
||||
@@ -66,7 +66,7 @@ func TestNewMember(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Member{
|
||||
Fields: &common.Fields{MaxResults: math.MaxInt64},
|
||||
Fields: common.Fields{MaxResults: math.MaxInt64},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -77,7 +77,7 @@ func TestNewMember(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Member{
|
||||
Fields: &common.Fields{MaxResults: 1},
|
||||
Fields: common.Fields{MaxResults: 1},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -90,7 +90,7 @@ func TestNewMember(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Member{
|
||||
Fields: &common.Fields{},
|
||||
Fields: common.Fields{},
|
||||
MemberChannelId: "",
|
||||
HasAccessToLevel: "",
|
||||
Mode: "",
|
||||
@@ -106,7 +106,7 @@ func TestNewMember(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Member{
|
||||
Fields: &common.Fields{
|
||||
Fields: common.Fields{
|
||||
Parts: []string{"id"},
|
||||
MaxResults: 50,
|
||||
},
|
||||
|
||||
@@ -17,7 +17,7 @@ var (
|
||||
)
|
||||
|
||||
type MembershipsLevel struct {
|
||||
*common.Fields
|
||||
common.Fields
|
||||
}
|
||||
|
||||
type IMembershipsLevel[T any] interface {
|
||||
@@ -28,16 +28,13 @@ type IMembershipsLevel[T any] interface {
|
||||
type Option func(*MembershipsLevel)
|
||||
|
||||
func NewMembershipsLevel(opts ...Option) IMembershipsLevel[youtube.MembershipsLevel] {
|
||||
m := &MembershipsLevel{Fields: &common.Fields{}}
|
||||
m := &MembershipsLevel{Fields: common.Fields{}}
|
||||
for _, opt := range opts {
|
||||
opt(m)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
func (m *MembershipsLevel) GetFields() *common.Fields {
|
||||
return m.Fields
|
||||
}
|
||||
|
||||
func (m *MembershipsLevel) Get() ([]*youtube.MembershipsLevel, error) {
|
||||
if err := m.EnsureService(); err != nil {
|
||||
|
||||
@@ -35,7 +35,7 @@ func TestNewMembershipsLevel(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &MembershipsLevel{
|
||||
Fields: &common.Fields{
|
||||
Fields: common.Fields{
|
||||
Service: svc,
|
||||
Parts: []string{"snippet"},
|
||||
Output: "json",
|
||||
@@ -47,7 +47,7 @@ func TestNewMembershipsLevel(t *testing.T) {
|
||||
args: args{
|
||||
opts: []Option{},
|
||||
},
|
||||
want: &MembershipsLevel{Fields: &common.Fields{}},
|
||||
want: &MembershipsLevel{Fields: common.Fields{}},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ var (
|
||||
)
|
||||
|
||||
type Playlist struct {
|
||||
*common.Fields
|
||||
common.Fields
|
||||
Title string `yaml:"title" json:"title,omitempty"`
|
||||
Description string `yaml:"description" json:"description,omitempty"`
|
||||
Mine *bool `yaml:"mine" json:"mine,omitempty"`
|
||||
@@ -43,7 +43,7 @@ type IPlaylist[T any] interface {
|
||||
type Option func(*Playlist)
|
||||
|
||||
func NewPlaylist(opts ...Option) IPlaylist[youtube.Playlist] {
|
||||
p := &Playlist{Fields: &common.Fields{}}
|
||||
p := &Playlist{Fields: common.Fields{}}
|
||||
for _, opt := range opts {
|
||||
opt(p)
|
||||
}
|
||||
@@ -76,7 +76,7 @@ func (p *Playlist) Get() ([]*youtube.Playlist, error) {
|
||||
}
|
||||
|
||||
return common.Paginate(
|
||||
p.Fields, call,
|
||||
&p.Fields, call,
|
||||
func(r *youtube.PlaylistListResponse) ([]*youtube.Playlist, string) {
|
||||
return r.Items, r.NextPageToken
|
||||
}, errGetPlaylist,
|
||||
|
||||
@@ -53,7 +53,7 @@ func TestNewPlaylist(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Playlist{
|
||||
Fields: &common.Fields{
|
||||
Fields: common.Fields{
|
||||
Service: svc,
|
||||
Parts: []string{"id", "snippet"},
|
||||
Output: "json",
|
||||
@@ -77,7 +77,7 @@ func TestNewPlaylist(t *testing.T) {
|
||||
args: args{
|
||||
opts: []Option{},
|
||||
},
|
||||
want: &Playlist{Fields: &common.Fields{}},
|
||||
want: &Playlist{Fields: common.Fields{}},
|
||||
},
|
||||
{
|
||||
name: "with nil boolean options",
|
||||
@@ -86,7 +86,7 @@ func TestNewPlaylist(t *testing.T) {
|
||||
WithMine(nil),
|
||||
},
|
||||
},
|
||||
want: &Playlist{Fields: &common.Fields{}},
|
||||
want: &Playlist{Fields: common.Fields{}},
|
||||
},
|
||||
{
|
||||
name: "with false boolean options",
|
||||
@@ -96,7 +96,7 @@ func TestNewPlaylist(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Playlist{
|
||||
Fields: &common.Fields{},
|
||||
Fields: common.Fields{},
|
||||
Mine: &mineFalse,
|
||||
},
|
||||
},
|
||||
@@ -108,7 +108,7 @@ func TestNewPlaylist(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Playlist{
|
||||
Fields: &common.Fields{MaxResults: math.MaxInt64},
|
||||
Fields: common.Fields{MaxResults: math.MaxInt64},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -119,7 +119,7 @@ func TestNewPlaylist(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Playlist{
|
||||
Fields: &common.Fields{MaxResults: 1},
|
||||
Fields: common.Fields{MaxResults: 1},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -137,7 +137,7 @@ func TestNewPlaylist(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Playlist{
|
||||
Fields: &common.Fields{},
|
||||
Fields: common.Fields{},
|
||||
Title: "",
|
||||
Description: "",
|
||||
Language: "",
|
||||
@@ -156,7 +156,7 @@ func TestNewPlaylist(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Playlist{
|
||||
Fields: &common.Fields{MaxResults: 25},
|
||||
Fields: common.Fields{MaxResults: 25},
|
||||
Title: "My Playlist",
|
||||
Description: "A great playlist",
|
||||
Privacy: "private",
|
||||
|
||||
@@ -23,7 +23,7 @@ var (
|
||||
)
|
||||
|
||||
type PlaylistImage struct {
|
||||
*common.Fields
|
||||
common.Fields
|
||||
Height int64 `yaml:"height" json:"height,omitempty"`
|
||||
PlaylistId string `yaml:"playlist_id" json:"playlist_id,omitempty"`
|
||||
Type string `yaml:"type" json:"type,omitempty"`
|
||||
@@ -45,7 +45,7 @@ type IPlaylistImage[T any] interface {
|
||||
type Option func(*PlaylistImage)
|
||||
|
||||
func NewPlaylistImage(opts ...Option) IPlaylistImage[youtube.PlaylistImage] {
|
||||
pi := &PlaylistImage{Fields: &common.Fields{}}
|
||||
pi := &PlaylistImage{Fields: common.Fields{}}
|
||||
for _, opt := range opts {
|
||||
opt(pi)
|
||||
}
|
||||
@@ -69,7 +69,7 @@ func (pi *PlaylistImage) Get() ([]*youtube.PlaylistImage, error) {
|
||||
}
|
||||
|
||||
return common.Paginate(
|
||||
pi.Fields, call,
|
||||
&pi.Fields, call,
|
||||
func(r *youtube.PlaylistImageListResponse) ([]*youtube.PlaylistImage, string) {
|
||||
return r.Items, r.NextPageToken
|
||||
}, errGetPlaylistImage,
|
||||
|
||||
@@ -48,7 +48,7 @@ func TestNewPlaylistImage(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &PlaylistImage{
|
||||
Fields: &common.Fields{
|
||||
Fields: common.Fields{
|
||||
Service: svc,
|
||||
Parts: []string{"id", "snippet"},
|
||||
Output: "json",
|
||||
@@ -70,7 +70,7 @@ func TestNewPlaylistImage(t *testing.T) {
|
||||
args: args{
|
||||
opts: []Option{},
|
||||
},
|
||||
want: &PlaylistImage{Fields: &common.Fields{}},
|
||||
want: &PlaylistImage{Fields: common.Fields{}},
|
||||
},
|
||||
{
|
||||
name: "with zero max results",
|
||||
@@ -80,7 +80,7 @@ func TestNewPlaylistImage(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &PlaylistImage{
|
||||
Fields: &common.Fields{MaxResults: math.MaxInt64},
|
||||
Fields: common.Fields{MaxResults: math.MaxInt64},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -91,7 +91,7 @@ func TestNewPlaylistImage(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &PlaylistImage{
|
||||
Fields: &common.Fields{MaxResults: 1},
|
||||
Fields: common.Fields{MaxResults: 1},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -107,7 +107,7 @@ func TestNewPlaylistImage(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &PlaylistImage{
|
||||
Fields: &common.Fields{
|
||||
Fields: common.Fields{
|
||||
OnBehalfOfContentOwner: "",
|
||||
},
|
||||
PlaylistId: "",
|
||||
@@ -128,7 +128,7 @@ func TestNewPlaylistImage(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &PlaylistImage{
|
||||
Fields: &common.Fields{
|
||||
Fields: common.Fields{
|
||||
MaxResults: 25,
|
||||
},
|
||||
PlaylistId: "myPlaylist",
|
||||
|
||||
@@ -21,7 +21,7 @@ var (
|
||||
)
|
||||
|
||||
type PlaylistItem struct {
|
||||
*common.Fields
|
||||
common.Fields
|
||||
Title string `yaml:"title" json:"title,omitempty"`
|
||||
Description string `yaml:"description" json:"description,omitempty"`
|
||||
Kind string `yaml:"kind" json:"kind,omitempty"`
|
||||
@@ -44,7 +44,7 @@ type IPlaylistItem[T any] interface {
|
||||
type Option func(*PlaylistItem)
|
||||
|
||||
func NewPlaylistItem(opts ...Option) IPlaylistItem[youtube.PlaylistItem] {
|
||||
p := &PlaylistItem{Fields: &common.Fields{}}
|
||||
p := &PlaylistItem{Fields: common.Fields{}}
|
||||
for _, opt := range opts {
|
||||
opt(p)
|
||||
}
|
||||
@@ -70,7 +70,7 @@ func (pi *PlaylistItem) Get() ([]*youtube.PlaylistItem, error) {
|
||||
}
|
||||
|
||||
return common.Paginate(
|
||||
pi.Fields, call,
|
||||
&pi.Fields, call,
|
||||
func(r *youtube.PlaylistItemListResponse) ([]*youtube.PlaylistItem, string) {
|
||||
return r.Items, r.NextPageToken
|
||||
}, errGetPlaylistItem,
|
||||
|
||||
@@ -51,7 +51,7 @@ func TestNewPlaylistItem(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &PlaylistItem{
|
||||
Fields: &common.Fields{
|
||||
Fields: common.Fields{
|
||||
Service: svc,
|
||||
Parts: []string{"snippet", "status"},
|
||||
Output: "json",
|
||||
@@ -76,7 +76,7 @@ func TestNewPlaylistItem(t *testing.T) {
|
||||
args: args{
|
||||
opts: []Option{},
|
||||
},
|
||||
want: &PlaylistItem{Fields: &common.Fields{}},
|
||||
want: &PlaylistItem{Fields: common.Fields{}},
|
||||
},
|
||||
{
|
||||
name: "with zero max results",
|
||||
@@ -86,7 +86,7 @@ func TestNewPlaylistItem(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &PlaylistItem{
|
||||
Fields: &common.Fields{MaxResults: math.MaxInt64},
|
||||
Fields: common.Fields{MaxResults: math.MaxInt64},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -97,7 +97,7 @@ func TestNewPlaylistItem(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &PlaylistItem{
|
||||
Fields: &common.Fields{MaxResults: 1},
|
||||
Fields: common.Fields{MaxResults: 1},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -119,7 +119,7 @@ func TestNewPlaylistItem(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &PlaylistItem{
|
||||
Fields: &common.Fields{
|
||||
Fields: common.Fields{
|
||||
Output: "",
|
||||
ChannelId: "",
|
||||
OnBehalfOfContentOwner: "",
|
||||
@@ -148,7 +148,7 @@ func TestNewPlaylistItem(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &PlaylistItem{
|
||||
Fields: &common.Fields{
|
||||
Fields: common.Fields{
|
||||
Parts: []string{"id"},
|
||||
MaxResults: 25,
|
||||
},
|
||||
|
||||
@@ -17,7 +17,7 @@ var (
|
||||
)
|
||||
|
||||
type Search struct {
|
||||
*common.Fields
|
||||
common.Fields
|
||||
ChannelType string `yaml:"channel_type" json:"channel_type,omitempty"`
|
||||
EventType string `yaml:"event_type" json:"event_type,omitempty"`
|
||||
ForContentOwner *bool `yaml:"for_content_owner" json:"for_content_owner,omitempty"`
|
||||
@@ -54,7 +54,7 @@ type ISearch[T any] interface {
|
||||
type Option func(*Search)
|
||||
|
||||
func NewSearch(opts ...Option) ISearch[youtube.SearchResult] {
|
||||
s := &Search{Fields: &common.Fields{}}
|
||||
s := &Search{Fields: common.Fields{}}
|
||||
for _, opt := range opts {
|
||||
opt(s)
|
||||
}
|
||||
@@ -152,7 +152,7 @@ func (s *Search) Get() ([]*youtube.SearchResult, error) {
|
||||
}
|
||||
|
||||
return common.Paginate(
|
||||
s.Fields, call,
|
||||
&s.Fields, call,
|
||||
func(r *youtube.SearchListResponse) ([]*youtube.SearchResult, string) {
|
||||
return r.Items, r.NextPageToken
|
||||
}, errGetSearch,
|
||||
|
||||
@@ -73,7 +73,7 @@ func TestNewSearch(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Search{
|
||||
Fields: &common.Fields{
|
||||
Fields: common.Fields{
|
||||
Service: svc,
|
||||
Parts: []string{"snippet"},
|
||||
Output: "json",
|
||||
@@ -114,7 +114,7 @@ func TestNewSearch(t *testing.T) {
|
||||
args: args{
|
||||
opts: []Option{},
|
||||
},
|
||||
want: &Search{Fields: &common.Fields{}},
|
||||
want: &Search{Fields: common.Fields{}},
|
||||
},
|
||||
{
|
||||
name: "with nil boolean options",
|
||||
@@ -125,7 +125,7 @@ func TestNewSearch(t *testing.T) {
|
||||
WithForMine(nil),
|
||||
},
|
||||
},
|
||||
want: &Search{Fields: &common.Fields{}},
|
||||
want: &Search{Fields: common.Fields{}},
|
||||
},
|
||||
{
|
||||
name: "with false boolean options",
|
||||
@@ -137,7 +137,7 @@ func TestNewSearch(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Search{
|
||||
Fields: &common.Fields{},
|
||||
Fields: common.Fields{},
|
||||
ForContentOwner: &forContentOwnerFalse,
|
||||
ForDeveloper: &forDeveloperFalse,
|
||||
ForMine: &forMineFalse,
|
||||
@@ -151,7 +151,7 @@ func TestNewSearch(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Search{
|
||||
Fields: &common.Fields{MaxResults: math.MaxInt64},
|
||||
Fields: common.Fields{MaxResults: math.MaxInt64},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -162,7 +162,7 @@ func TestNewSearch(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Search{
|
||||
Fields: &common.Fields{MaxResults: 1},
|
||||
Fields: common.Fields{MaxResults: 1},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -196,7 +196,7 @@ func TestNewSearch(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Search{
|
||||
Fields: &common.Fields{
|
||||
Fields: common.Fields{
|
||||
ChannelId: "",
|
||||
OnBehalfOfContentOwner: "",
|
||||
},
|
||||
@@ -236,7 +236,7 @@ func TestNewSearch(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Search{
|
||||
Fields: &common.Fields{MaxResults: 25},
|
||||
Fields: common.Fields{MaxResults: 25},
|
||||
Q: "golang tutorial",
|
||||
Order: "date",
|
||||
RegionCode: "UK",
|
||||
|
||||
@@ -20,7 +20,7 @@ var (
|
||||
)
|
||||
|
||||
type Subscription struct {
|
||||
*common.Fields
|
||||
common.Fields
|
||||
SubscriberChannelId string `yaml:"subscriber_channel_id" json:"subscriber_channel_id,omitempty"`
|
||||
Description string `yaml:"description" json:"description,omitempty"`
|
||||
ForChannelId string `yaml:"for_channel_id" json:"for_channel_id,omitempty"`
|
||||
@@ -43,7 +43,7 @@ type ISubscription[T any] interface {
|
||||
type Option func(*Subscription)
|
||||
|
||||
func NewSubscription(opts ...Option) ISubscription[youtube.Subscription] {
|
||||
s := &Subscription{Fields: &common.Fields{}}
|
||||
s := &Subscription{Fields: common.Fields{}}
|
||||
for _, opt := range opts {
|
||||
opt(s)
|
||||
}
|
||||
@@ -84,7 +84,7 @@ func (s *Subscription) Get() ([]*youtube.Subscription, error) {
|
||||
}
|
||||
|
||||
return common.Paginate(
|
||||
s.Fields, call,
|
||||
&s.Fields, call,
|
||||
func(r *youtube.SubscriptionListResponse) ([]*youtube.Subscription, string) {
|
||||
return r.Items, r.NextPageToken
|
||||
}, errGetSubscription,
|
||||
|
||||
@@ -57,7 +57,7 @@ func TestNewSubscription(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Subscription{
|
||||
Fields: &common.Fields{
|
||||
Fields: common.Fields{
|
||||
Service: svc,
|
||||
Parts: []string{"snippet", "contentDetails"},
|
||||
Output: "json",
|
||||
@@ -82,7 +82,7 @@ func TestNewSubscription(t *testing.T) {
|
||||
args: args{
|
||||
opts: []Option{},
|
||||
},
|
||||
want: &Subscription{Fields: &common.Fields{}},
|
||||
want: &Subscription{Fields: common.Fields{}},
|
||||
},
|
||||
{
|
||||
name: "with nil boolean options",
|
||||
@@ -93,7 +93,7 @@ func TestNewSubscription(t *testing.T) {
|
||||
WithMySubscribers(nil),
|
||||
},
|
||||
},
|
||||
want: &Subscription{Fields: &common.Fields{}},
|
||||
want: &Subscription{Fields: common.Fields{}},
|
||||
},
|
||||
{
|
||||
name: "with false boolean options",
|
||||
@@ -105,7 +105,7 @@ func TestNewSubscription(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Subscription{
|
||||
Fields: &common.Fields{},
|
||||
Fields: common.Fields{},
|
||||
Mine: &mineFalse,
|
||||
MyRecentSubscribers: &myRecentSubscribersFalse,
|
||||
MySubscribers: &mySubscribersFalse,
|
||||
@@ -119,7 +119,7 @@ func TestNewSubscription(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Subscription{
|
||||
Fields: &common.Fields{MaxResults: math.MaxInt64},
|
||||
Fields: common.Fields{MaxResults: math.MaxInt64},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -130,7 +130,7 @@ func TestNewSubscription(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Subscription{
|
||||
Fields: &common.Fields{MaxResults: 1},
|
||||
Fields: common.Fields{MaxResults: 1},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -148,7 +148,7 @@ func TestNewSubscription(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Subscription{
|
||||
Fields: &common.Fields{
|
||||
Fields: common.Fields{
|
||||
ChannelId: "",
|
||||
OnBehalfOfContentOwner: "",
|
||||
},
|
||||
@@ -172,7 +172,7 @@ func TestNewSubscription(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Subscription{
|
||||
Fields: &common.Fields{
|
||||
Fields: common.Fields{
|
||||
ChannelId: "myChannel",
|
||||
MaxResults: 25,
|
||||
},
|
||||
|
||||
@@ -17,7 +17,7 @@ var (
|
||||
)
|
||||
|
||||
type SuperChatEvent struct {
|
||||
*common.Fields
|
||||
common.Fields
|
||||
}
|
||||
|
||||
type ISuperChatEvent[T any] interface {
|
||||
@@ -28,7 +28,7 @@ type ISuperChatEvent[T any] interface {
|
||||
type Option func(*SuperChatEvent)
|
||||
|
||||
func NewSuperChatEvent(opts ...Option) ISuperChatEvent[youtube.SuperChatEvent] {
|
||||
s := &SuperChatEvent{Fields: &common.Fields{}}
|
||||
s := &SuperChatEvent{Fields: common.Fields{}}
|
||||
for _, opt := range opts {
|
||||
opt(s)
|
||||
}
|
||||
@@ -45,7 +45,7 @@ func (s *SuperChatEvent) Get() ([]*youtube.SuperChatEvent, error) {
|
||||
}
|
||||
|
||||
return common.Paginate(
|
||||
s.Fields, call,
|
||||
&s.Fields, call,
|
||||
func(r *youtube.SuperChatEventListResponse) ([]*youtube.SuperChatEvent, string) {
|
||||
return r.Items, r.NextPageToken
|
||||
}, errGetSuperChatEvent,
|
||||
|
||||
@@ -38,7 +38,7 @@ func TestNewSuperChatEvent(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &SuperChatEvent{
|
||||
Fields: &common.Fields{
|
||||
Fields: common.Fields{
|
||||
Service: svc,
|
||||
Parts: []string{"id", "snippet"},
|
||||
Output: "json",
|
||||
@@ -52,7 +52,7 @@ func TestNewSuperChatEvent(t *testing.T) {
|
||||
args: args{
|
||||
opts: []Option{},
|
||||
},
|
||||
want: &SuperChatEvent{Fields: &common.Fields{}},
|
||||
want: &SuperChatEvent{Fields: common.Fields{}},
|
||||
},
|
||||
{
|
||||
name: "with zero max results",
|
||||
@@ -62,7 +62,7 @@ func TestNewSuperChatEvent(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &SuperChatEvent{
|
||||
Fields: &common.Fields{MaxResults: math.MaxInt64},
|
||||
Fields: common.Fields{MaxResults: math.MaxInt64},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -73,7 +73,7 @@ func TestNewSuperChatEvent(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &SuperChatEvent{
|
||||
Fields: &common.Fields{MaxResults: 1},
|
||||
Fields: common.Fields{MaxResults: 1},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -85,7 +85,7 @@ func TestNewSuperChatEvent(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &SuperChatEvent{
|
||||
Fields: &common.Fields{Output: "", Hl: ""},
|
||||
Fields: common.Fields{Output: "", Hl: ""},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -98,7 +98,7 @@ func TestNewSuperChatEvent(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &SuperChatEvent{
|
||||
Fields: &common.Fields{
|
||||
Fields: common.Fields{
|
||||
Output: "yaml",
|
||||
Hl: "ja",
|
||||
MaxResults: 25,
|
||||
|
||||
@@ -16,7 +16,7 @@ var (
|
||||
)
|
||||
|
||||
type Thumbnail struct {
|
||||
*common.Fields
|
||||
common.Fields
|
||||
File string `yaml:"file" json:"file,omitempty"`
|
||||
VideoId string `yaml:"video_id" json:"video_id,omitempty"`
|
||||
}
|
||||
@@ -28,7 +28,7 @@ type IThumbnail interface {
|
||||
type Option func(*Thumbnail)
|
||||
|
||||
func NewThumbnail(opts ...Option) IThumbnail {
|
||||
t := &Thumbnail{Fields: &common.Fields{}}
|
||||
t := &Thumbnail{Fields: common.Fields{}}
|
||||
for _, opt := range opts {
|
||||
opt(t)
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ func TestNewThumbnail(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Thumbnail{
|
||||
Fields: &common.Fields{
|
||||
Fields: common.Fields{
|
||||
Service: svc,
|
||||
Output: "json",
|
||||
},
|
||||
@@ -49,7 +49,7 @@ func TestNewThumbnail(t *testing.T) {
|
||||
args: args{
|
||||
opts: []Option{},
|
||||
},
|
||||
want: &Thumbnail{Fields: &common.Fields{}},
|
||||
want: &Thumbnail{Fields: common.Fields{}},
|
||||
},
|
||||
{
|
||||
name: "with empty string values",
|
||||
@@ -61,7 +61,7 @@ func TestNewThumbnail(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Thumbnail{
|
||||
Fields: &common.Fields{
|
||||
Fields: common.Fields{
|
||||
Output: "",
|
||||
},
|
||||
VideoId: "",
|
||||
@@ -77,7 +77,7 @@ func TestNewThumbnail(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Thumbnail{
|
||||
Fields: &common.Fields{},
|
||||
Fields: common.Fields{},
|
||||
VideoId: "myVideo123",
|
||||
File: "/images/thumb.png",
|
||||
},
|
||||
|
||||
+3
-3
@@ -31,7 +31,7 @@ var (
|
||||
)
|
||||
|
||||
type Video struct {
|
||||
*common.Fields
|
||||
common.Fields
|
||||
AutoLevels *bool `yaml:"auto_levels" json:"auto_levels,omitempty"`
|
||||
File string `yaml:"file" json:"file,omitempty"`
|
||||
Title string `yaml:"title" json:"title,omitempty"`
|
||||
@@ -78,7 +78,7 @@ type IVideo[T any] interface {
|
||||
type Option func(*Video)
|
||||
|
||||
func NewVideo(opts ...Option) IVideo[youtube.Video] {
|
||||
v := &Video{Fields: &common.Fields{}}
|
||||
v := &Video{Fields: common.Fields{}}
|
||||
for _, opt := range opts {
|
||||
opt(v)
|
||||
}
|
||||
@@ -122,7 +122,7 @@ func (v *Video) Get() ([]*youtube.Video, error) {
|
||||
}
|
||||
|
||||
return common.Paginate(
|
||||
v.Fields, call,
|
||||
&v.Fields, call,
|
||||
func(r *youtube.VideoListResponse) ([]*youtube.Video, string) {
|
||||
return r.Items, r.NextPageToken
|
||||
}, errGetVideo,
|
||||
|
||||
@@ -91,7 +91,7 @@ func TestNewVideo(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Video{
|
||||
Fields: &common.Fields{
|
||||
Fields: common.Fields{
|
||||
Service: svc,
|
||||
Parts: []string{"snippet", "contentDetails"},
|
||||
Output: "json",
|
||||
@@ -137,7 +137,7 @@ func TestNewVideo(t *testing.T) {
|
||||
args: args{
|
||||
opts: []Option{},
|
||||
},
|
||||
want: &Video{Fields: &common.Fields{}},
|
||||
want: &Video{Fields: common.Fields{}},
|
||||
},
|
||||
{
|
||||
name: "with nil boolean options",
|
||||
@@ -152,7 +152,7 @@ func TestNewVideo(t *testing.T) {
|
||||
WithPublicStatsViewable(nil),
|
||||
},
|
||||
},
|
||||
want: &Video{Fields: &common.Fields{}},
|
||||
want: &Video{Fields: common.Fields{}},
|
||||
},
|
||||
{
|
||||
name: "with false boolean options",
|
||||
@@ -168,7 +168,7 @@ func TestNewVideo(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Video{
|
||||
Fields: &common.Fields{},
|
||||
Fields: common.Fields{},
|
||||
AutoLevels: &autoLevelsFalse,
|
||||
ForKids: &forKidsFalse,
|
||||
Embeddable: &embeddableFalse,
|
||||
@@ -186,7 +186,7 @@ func TestNewVideo(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Video{
|
||||
Fields: &common.Fields{MaxResults: math.MaxInt64},
|
||||
Fields: common.Fields{MaxResults: math.MaxInt64},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -197,7 +197,7 @@ func TestNewVideo(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Video{
|
||||
Fields: &common.Fields{MaxResults: 1},
|
||||
Fields: common.Fields{MaxResults: 1},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -229,7 +229,7 @@ func TestNewVideo(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Video{
|
||||
Fields: &common.Fields{},
|
||||
Fields: common.Fields{},
|
||||
File: "",
|
||||
Title: "",
|
||||
Description: "",
|
||||
@@ -264,7 +264,7 @@ func TestNewVideo(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Video{
|
||||
Fields: &common.Fields{MaxResults: 25},
|
||||
Fields: common.Fields{MaxResults: 25},
|
||||
Title: "My Video",
|
||||
Description: "A great video",
|
||||
Tags: []string{"tutorial", "golang"},
|
||||
|
||||
@@ -17,7 +17,7 @@ var (
|
||||
)
|
||||
|
||||
type VideoAbuseReportReason struct {
|
||||
*common.Fields
|
||||
common.Fields
|
||||
}
|
||||
|
||||
type IVideoAbuseReportReason[T any] interface {
|
||||
@@ -28,7 +28,7 @@ type IVideoAbuseReportReason[T any] interface {
|
||||
type Option func(*VideoAbuseReportReason)
|
||||
|
||||
func NewVideoAbuseReportReason(opt ...Option) IVideoAbuseReportReason[youtube.VideoAbuseReportReason] {
|
||||
va := &VideoAbuseReportReason{Fields: &common.Fields{}}
|
||||
va := &VideoAbuseReportReason{Fields: common.Fields{}}
|
||||
for _, o := range opt {
|
||||
o(va)
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ func TestNewVideoAbuseReportReason(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &VideoAbuseReportReason{
|
||||
Fields: &common.Fields{
|
||||
Fields: common.Fields{
|
||||
Service: svc,
|
||||
Parts: []string{"id", "snippet"},
|
||||
Output: "json",
|
||||
@@ -49,7 +49,7 @@ func TestNewVideoAbuseReportReason(t *testing.T) {
|
||||
args: args{
|
||||
opts: []Option{},
|
||||
},
|
||||
want: &VideoAbuseReportReason{Fields: &common.Fields{}},
|
||||
want: &VideoAbuseReportReason{Fields: common.Fields{}},
|
||||
},
|
||||
{
|
||||
name: "with empty string values",
|
||||
@@ -60,7 +60,7 @@ func TestNewVideoAbuseReportReason(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &VideoAbuseReportReason{
|
||||
Fields: &common.Fields{
|
||||
Fields: common.Fields{
|
||||
Output: "",
|
||||
Hl: "",
|
||||
},
|
||||
@@ -75,7 +75,7 @@ func TestNewVideoAbuseReportReason(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &VideoAbuseReportReason{
|
||||
Fields: &common.Fields{
|
||||
Fields: common.Fields{
|
||||
Parts: []string{"snippet"},
|
||||
Hl: "ja",
|
||||
},
|
||||
|
||||
@@ -17,7 +17,7 @@ var (
|
||||
)
|
||||
|
||||
type VideoCategory struct {
|
||||
*common.Fields
|
||||
common.Fields
|
||||
RegionCode string `yaml:"region_code" json:"region_code,omitempty"`
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ type IVideoCategory[T any] interface {
|
||||
type Option func(*VideoCategory)
|
||||
|
||||
func NewVideoCategory(opt ...Option) IVideoCategory[youtube.VideoCategory] {
|
||||
vc := &VideoCategory{Fields: &common.Fields{}}
|
||||
vc := &VideoCategory{Fields: common.Fields{}}
|
||||
for _, o := range opt {
|
||||
o(vc)
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ func TestNewVideoCategory(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &VideoCategory{
|
||||
Fields: &common.Fields{
|
||||
Fields: common.Fields{
|
||||
Service: svc,
|
||||
Parts: []string{"snippet"},
|
||||
Output: "json",
|
||||
@@ -53,7 +53,7 @@ func TestNewVideoCategory(t *testing.T) {
|
||||
args: args{
|
||||
opts: []Option{},
|
||||
},
|
||||
want: &VideoCategory{Fields: &common.Fields{}},
|
||||
want: &VideoCategory{Fields: common.Fields{}},
|
||||
},
|
||||
{
|
||||
name: "with empty string values",
|
||||
@@ -64,7 +64,7 @@ func TestNewVideoCategory(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &VideoCategory{
|
||||
Fields: &common.Fields{Hl: ""},
|
||||
Fields: common.Fields{Hl: ""},
|
||||
RegionCode: "",
|
||||
},
|
||||
},
|
||||
@@ -77,7 +77,7 @@ func TestNewVideoCategory(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &VideoCategory{
|
||||
Fields: &common.Fields{Hl: "ja"},
|
||||
Fields: common.Fields{Hl: "ja"},
|
||||
RegionCode: "JP",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -20,7 +20,7 @@ var (
|
||||
)
|
||||
|
||||
type Watermark struct {
|
||||
*common.Fields
|
||||
common.Fields
|
||||
File string `yaml:"file" json:"file,omitempty"`
|
||||
InVideoPosition string `yaml:"in_video_position" json:"in_video_position,omitempty"`
|
||||
DurationMs uint64 `yaml:"duration_ms" json:"duration_ms,omitempty"`
|
||||
@@ -36,7 +36,7 @@ type IWatermark interface {
|
||||
type Option func(*Watermark)
|
||||
|
||||
func NewWatermark(opts ...Option) IWatermark {
|
||||
w := &Watermark{Fields: &common.Fields{}}
|
||||
w := &Watermark{Fields: common.Fields{}}
|
||||
for _, opt := range opts {
|
||||
opt(w)
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ func TestNewWatermark(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Watermark{
|
||||
Fields: &common.Fields{
|
||||
Fields: common.Fields{
|
||||
Service: svc,
|
||||
ChannelId: "channel123",
|
||||
OnBehalfOfContentOwner: "owner123",
|
||||
@@ -58,7 +58,7 @@ func TestNewWatermark(t *testing.T) {
|
||||
args: args{
|
||||
opts: []Option{},
|
||||
},
|
||||
want: &Watermark{Fields: &common.Fields{}},
|
||||
want: &Watermark{Fields: common.Fields{}},
|
||||
},
|
||||
{
|
||||
name: "with zero values",
|
||||
@@ -69,7 +69,7 @@ func TestNewWatermark(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Watermark{
|
||||
Fields: &common.Fields{},
|
||||
Fields: common.Fields{},
|
||||
DurationMs: 0,
|
||||
OffsetMs: 0,
|
||||
},
|
||||
@@ -86,7 +86,7 @@ func TestNewWatermark(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Watermark{
|
||||
Fields: &common.Fields{
|
||||
Fields: common.Fields{
|
||||
ChannelId: "",
|
||||
OnBehalfOfContentOwner: "",
|
||||
},
|
||||
@@ -106,7 +106,7 @@ func TestNewWatermark(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: &Watermark{
|
||||
Fields: &common.Fields{ChannelId: "myChannel"},
|
||||
Fields: common.Fields{ChannelId: "myChannel"},
|
||||
File: "/watermarks/logo.png",
|
||||
InVideoPosition: "bottomLeft",
|
||||
DurationMs: 10000,
|
||||
|
||||
Reference in new issue
Block a user