fix: add GroupsSectionsList
@@ -4,10 +4,13 @@ import (
"testing"
"github.com/SevereCloud/vksdk/object"
+ "github.com/stretchr/testify/assert"
)
func TestGroupsGroup_ToMention(t *testing.T) {
f := func(group object.GroupsGroup, want string) {
+ t.Helper()
+
if got := group.ToMention(); got != want {
t.Errorf("GroupsGroup.ToMention() = %v, want %v", got, want)
}
@@ -21,6 +24,8 @@ func TestGroupsGroup_ToMention(t *testing.T) {
func TestGroupsGroupXtrInvitedBy_ToMention(t *testing.T) {
f := func(group object.GroupsGroupXtrInvitedBy, want string) {
+ t.Helper()
+
if got := group.ToMention(); got != want {
t.Errorf("GroupsGroupXtrInvitedBy.ToMention() = %v, want %v", got, want)
}
@@ -31,3 +36,48 @@ func TestGroupsGroupXtrInvitedBy_ToMention(t *testing.T) {
"[club1|Api club]",
)
}
+
+func TestGroupsSectionsList_UnmarshalJSON(t *testing.T) {
+ f := func(data []byte, want object.GroupsSectionsList, wanErr bool) {
+ t.Helper()
+
+ var got object.GroupsSectionsList
+
+ err := got.UnmarshalJSON(data)
+
+ if wanErr {
+ assert.Error(t, err)
+ } else {
+ assert.NoError(t, err)
+ assert.Equal(t, want, got)
+ }
+ }
+
+ f(
+ []byte(`[123, "test"]`),
+ object.GroupsSectionsList{123, "test"},
+ false,
+ )
+
+ // Errors:
+ f(
+ []byte(`123`),
+ object.GroupsSectionsList{},
+ true,
+ )
+ f(
+ []byte(`[123, "123", "123"]`),
+ object.GroupsSectionsList{},
+ true,
+ )
+ f(
+ []byte(`["123", "123"]`),
+ object.GroupsSectionsList{},
+ true,
+ )
+ f(
+ []byte(`[123, 123]`),
+ object.GroupsSectionsList{},
+ true,
+ )
+}
