feat: add new commands - group set channel-losses/channel-gains (#13)
All checks were successful
continuous-integration/drone/push Build is passing

Reviewed-on: #13
This commit is contained in:
Dawid Wysokiński 2022-10-11 05:05:35 +00:00
parent 0436c56813
commit aec3a3736d
9 changed files with 299 additions and 133 deletions

View File

@ -24,8 +24,8 @@ func (g *Group) Create(ctx context.Context, params domain.CreateGroupParams) (do
group := model.Group{ group := model.Group{
ServerID: params.ServerID(), ServerID: params.ServerID(),
VersionCode: params.VersionCode(), VersionCode: params.VersionCode(),
ChannelGainedVillages: params.ChannelGainedVillages(), ChannelGains: params.ChannelGains(),
ChannelLostVillages: params.ChannelLostVillages(), ChannelLosses: params.ChannelLosses(),
ServerKey: params.ServerKey(), ServerKey: params.ServerKey(),
} }
@ -89,12 +89,12 @@ type updateGroupsParamsApplier struct {
} }
func (u updateGroupsParamsApplier) apply(q *bun.UpdateQuery) *bun.UpdateQuery { func (u updateGroupsParamsApplier) apply(q *bun.UpdateQuery) *bun.UpdateQuery {
if u.params.ChannelGainedVillages.Valid { if u.params.ChannelGains.Valid {
q = q.Set("channel_gained_villages = ?", u.params.ChannelGainedVillages.String) q = q.Set("channel_gains = ?", u.params.ChannelGains.String)
} }
if u.params.ChannelLostVillages.Valid { if u.params.ChannelLosses.Valid {
q = q.Set("channel_lost_villages = ?", u.params.ChannelLostVillages.String) q = q.Set("channel_losses = ?", u.params.ChannelLosses.String)
} }
if u.params.ServerKey.Valid { if u.params.ServerKey.Valid {

View File

@ -38,8 +38,8 @@ func TestGroup_Create(t *testing.T) {
assert.Equal(t, params.ServerID(), group.ServerID) assert.Equal(t, params.ServerID(), group.ServerID)
assert.Equal(t, params.ServerKey(), group.ServerKey) assert.Equal(t, params.ServerKey(), group.ServerKey)
assert.Equal(t, params.VersionCode(), group.VersionCode) assert.Equal(t, params.VersionCode(), group.VersionCode)
assert.Equal(t, params.ChannelGainedVillages(), group.ChannelGainedVillages) assert.Equal(t, params.ChannelGains(), group.ChannelGains)
assert.Equal(t, params.ChannelLostVillages(), group.ChannelLostVillages) assert.Equal(t, params.ChannelLosses(), group.ChannelLosses)
assert.WithinDuration(t, time.Now(), group.CreatedAt, 1*time.Second) assert.WithinDuration(t, time.Now(), group.CreatedAt, 1*time.Second)
}) })
} }
@ -56,12 +56,12 @@ func TestGroup_UpdateByID(t *testing.T) {
group := getGroupFromFixture(t, fixture, "group-server-1-1") group := getGroupFromFixture(t, fixture, "group-server-1-1")
params := domain.UpdateGroupParams{ params := domain.UpdateGroupParams{
ChannelGainedVillages: domain.NullString{ ChannelGains: domain.NullString{
String: group.ChannelGainedVillages + "update", String: group.ChannelGains + "update",
Valid: true, Valid: true,
}, },
ChannelLostVillages: domain.NullString{ ChannelLosses: domain.NullString{
String: group.ChannelLostVillages + "update", String: group.ChannelLosses + "update",
Valid: true, Valid: true,
}, },
ServerKey: domain.NullString{ ServerKey: domain.NullString{
@ -76,8 +76,8 @@ func TestGroup_UpdateByID(t *testing.T) {
updatedGroup, err := repo.UpdateByID(context.Background(), group.ID.String(), params) updatedGroup, err := repo.UpdateByID(context.Background(), group.ID.String(), params)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, params.ChannelGainedVillages.String, updatedGroup.ChannelGainedVillages) assert.Equal(t, params.ChannelGains.String, updatedGroup.ChannelGains)
assert.Equal(t, params.ChannelLostVillages.String, updatedGroup.ChannelLostVillages) assert.Equal(t, params.ChannelLosses.String, updatedGroup.ChannelLosses)
assert.Equal(t, params.ServerKey.String, updatedGroup.ServerKey) assert.Equal(t, params.ServerKey.String, updatedGroup.ServerKey)
assert.Equal(t, params.VersionCode.String, updatedGroup.VersionCode) assert.Equal(t, params.VersionCode.String, updatedGroup.VersionCode)
}) })
@ -95,7 +95,7 @@ func TestGroup_UpdateByID(t *testing.T) {
id := "12345" id := "12345"
updatedGroup, err := repo.UpdateByID(context.Background(), id, domain.UpdateGroupParams{ updatedGroup, err := repo.UpdateByID(context.Background(), id, domain.UpdateGroupParams{
ChannelGainedVillages: domain.NullString{ ChannelGains: domain.NullString{
String: "update", String: "update",
Valid: true, Valid: true,
}, },
@ -109,7 +109,7 @@ func TestGroup_UpdateByID(t *testing.T) {
id := uuid.NewString() id := uuid.NewString()
updatedGroup, err := repo.UpdateByID(context.Background(), id, domain.UpdateGroupParams{ updatedGroup, err := repo.UpdateByID(context.Background(), id, domain.UpdateGroupParams{
ChannelGainedVillages: domain.NullString{ ChannelGains: domain.NullString{
String: "update", String: "update",
Valid: true, Valid: true,
}, },

View File

@ -13,8 +13,8 @@ type Group struct {
ID uuid.UUID `bun:"id,type:uuid,pk,default:gen_random_uuid()"` ID uuid.UUID `bun:"id,type:uuid,pk,default:gen_random_uuid()"`
ServerID string `bun:"server_id,type:varchar(100),notnull"` ServerID string `bun:"server_id,type:varchar(100),notnull"`
ChannelGainedVillages string `bun:"channel_gained_villages,type:varchar(100),nullzero"` ChannelGains string `bun:"channel_gains,type:varchar(100),nullzero"`
ChannelLostVillages string `bun:"channel_lost_villages,type:varchar(100),nullzero"` ChannelLosses string `bun:"channel_losses,type:varchar(100),nullzero"`
ServerKey string `bun:"server_key,type:varchar(50),notnull"` ServerKey string `bun:"server_key,type:varchar(50),notnull"`
VersionCode string `bun:"version_code,type:varchar(6),notnull"` VersionCode string `bun:"version_code,type:varchar(6),notnull"`
CreatedAt time.Time `bun:"created_at,nullzero,notnull,default:current_timestamp"` CreatedAt time.Time `bun:"created_at,nullzero,notnull,default:current_timestamp"`
@ -24,8 +24,8 @@ func (g Group) ToDomain() domain.Group {
return domain.Group{ return domain.Group{
ID: g.ID.String(), ID: g.ID.String(),
ServerID: g.ServerID, ServerID: g.ServerID,
ChannelGainedVillages: g.ChannelGainedVillages, ChannelGains: g.ChannelGains,
ChannelLostVillages: g.ChannelLostVillages, ChannelLosses: g.ChannelLosses,
ServerKey: g.ServerKey, ServerKey: g.ServerKey,
VersionCode: g.VersionCode, VersionCode: g.VersionCode,
CreatedAt: g.CreatedAt, CreatedAt: g.CreatedAt,

View File

@ -12,6 +12,8 @@ import (
type GroupService interface { type GroupService interface {
Create(ctx context.Context, params domain.CreateGroupParams) (domain.Group, error) Create(ctx context.Context, params domain.CreateGroupParams) (domain.Group, error)
SetTWServer(ctx context.Context, id, versionCode, serverKey string) (domain.Group, error) SetTWServer(ctx context.Context, id, versionCode, serverKey string) (domain.Group, error)
SetChannelGains(ctx context.Context, id, channel string) (domain.Group, error)
SetChannelLosses(ctx context.Context, id, channel string) (domain.Group, error)
List(ctx context.Context, params domain.ListGroupsParams) ([]domain.Group, error) List(ctx context.Context, params domain.ListGroupsParams) ([]domain.Group, error)
} }

View File

@ -59,7 +59,7 @@ func (c *groupCommand) create(s *discordgo.Session) error {
Required: true, Required: true,
}, },
{ {
Name: "channel-gained-villages", Name: "channel-gains",
Description: "Specifies on which channel notifications of gained villages will appear", Description: "Specifies on which channel notifications of gained villages will appear",
Type: discordgo.ApplicationCommandOptionChannel, Type: discordgo.ApplicationCommandOptionChannel,
ChannelTypes: []discordgo.ChannelType{ ChannelTypes: []discordgo.ChannelType{
@ -68,7 +68,7 @@ func (c *groupCommand) create(s *discordgo.Session) error {
Required: false, Required: false,
}, },
{ {
Name: "channel-lost-villages", Name: "channel-losses",
Description: "Specifies on which channel notifications of lost villages will appear", Description: "Specifies on which channel notifications of lost villages will appear",
Type: discordgo.ApplicationCommandOptionChannel, Type: discordgo.ApplicationCommandOptionChannel,
ChannelTypes: []discordgo.ChannelType{ ChannelTypes: []discordgo.ChannelType{
@ -84,8 +84,13 @@ func (c *groupCommand) create(s *discordgo.Session) error {
Type: discordgo.ApplicationCommandOptionSubCommand, Type: discordgo.ApplicationCommandOptionSubCommand,
}, },
{ {
Name: "set-server", Name: "set",
Description: "Sets a Tribal Wars server (e.g. en115, pl170) for a group", Description: "Sets various properties in a group configuration",
Type: discordgo.ApplicationCommandOptionSubCommandGroup,
Options: []*discordgo.ApplicationCommandOption{
{
Name: "server",
Description: "Sets a Tribal Wars server for a group",
Type: discordgo.ApplicationCommandOptionSubCommand, Type: discordgo.ApplicationCommandOptionSubCommand,
Options: []*discordgo.ApplicationCommandOption{ Options: []*discordgo.ApplicationCommandOption{
{ {
@ -109,6 +114,52 @@ func (c *groupCommand) create(s *discordgo.Session) error {
}, },
}, },
}, },
{
Name: "channel-gains",
Description: "Specifies on which channel notifications of gained villages will appear",
Type: discordgo.ApplicationCommandOptionSubCommand,
Options: []*discordgo.ApplicationCommandOption{
{
Name: "group",
Description: "Group ID",
Type: discordgo.ApplicationCommandOptionString,
Required: true,
},
{
Name: "channel",
Description: "Channel",
Type: discordgo.ApplicationCommandOptionChannel,
ChannelTypes: []discordgo.ChannelType{
discordgo.ChannelTypeGuildText,
},
Required: true,
},
},
},
{
Name: "channel-losses",
Description: "Specifies on which channel notifications of lost villages will appear",
Type: discordgo.ApplicationCommandOptionSubCommand,
Options: []*discordgo.ApplicationCommandOption{
{
Name: "group",
Description: "Group ID",
Type: discordgo.ApplicationCommandOptionString,
Required: true,
},
{
Name: "channel",
Description: "Channel ID",
Type: discordgo.ApplicationCommandOptionChannel,
ChannelTypes: []discordgo.ChannelType{
discordgo.ChannelTypeGuildText,
},
Required: true,
},
},
},
},
},
}, },
}) })
if err != nil { if err != nil {
@ -147,8 +198,8 @@ func (c *groupCommand) handle(s *discordgo.Session, i *discordgo.InteractionCrea
case "list": case "list":
c.handleList(s, i) c.handleList(s, i)
return return
case "set-server": case "set":
c.handleSetServer(s, i) c.handleSet(s, i)
return return
default: default:
} }
@ -159,8 +210,8 @@ func (c *groupCommand) handleCreate(s *discordgo.Session, i *discordgo.Interacti
version := "" version := ""
server := "" server := ""
channelGainedVillages := "" channelGains := ""
channelLostVillages := "" channelLosses := ""
for _, opt := range i.ApplicationCommandData().Options[0].Options { for _, opt := range i.ApplicationCommandData().Options[0].Options {
if opt == nil { if opt == nil {
continue continue
@ -170,10 +221,10 @@ func (c *groupCommand) handleCreate(s *discordgo.Session, i *discordgo.Interacti
version = opt.StringValue() version = opt.StringValue()
case "server": case "server":
server = opt.StringValue() server = opt.StringValue()
case "channel-gained-villages": case "channel-gains":
channelGainedVillages = opt.ChannelValue(s).ID channelGains = opt.ChannelValue(s).ID
case "channel-lost-villages": case "channel-losses":
channelLostVillages = opt.ChannelValue(s).ID channelLosses = opt.ChannelValue(s).ID
} }
} }
@ -181,8 +232,8 @@ func (c *groupCommand) handleCreate(s *discordgo.Session, i *discordgo.Interacti
i.GuildID, i.GuildID,
version, version,
server, server,
channelGainedVillages, channelGains,
channelLostVillages, channelLosses,
) )
if err != nil { if err != nil {
_ = s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{ _ = s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
@ -244,13 +295,28 @@ func (c *groupCommand) handleList(s *discordgo.Session, i *discordgo.Interaction
}) })
} }
func (c *groupCommand) handleSet(s *discordgo.Session, i *discordgo.InteractionCreate) {
switch i.ApplicationCommandData().Options[0].Options[0].Name {
case "server":
c.handleSetServer(s, i)
return
case "channel-gains":
c.handleSetChannelGains(s, i)
return
case "channel-losses":
c.handleSetChannelLosses(s, i)
return
default:
}
}
func (c *groupCommand) handleSetServer(s *discordgo.Session, i *discordgo.InteractionCreate) { func (c *groupCommand) handleSetServer(s *discordgo.Session, i *discordgo.InteractionCreate) {
ctx := context.Background() ctx := context.Background()
group := "" group := ""
version := "" version := ""
server := "" server := ""
for _, opt := range i.ApplicationCommandData().Options[0].Options { for _, opt := range i.ApplicationCommandData().Options[0].Options[0].Options {
if opt == nil { if opt == nil {
continue continue
} }
@ -283,6 +349,78 @@ func (c *groupCommand) handleSetServer(s *discordgo.Session, i *discordgo.Intera
}) })
} }
func (c *groupCommand) handleSetChannelGains(s *discordgo.Session, i *discordgo.InteractionCreate) {
ctx := context.Background()
group := ""
channel := ""
for _, opt := range i.ApplicationCommandData().Options[0].Options[0].Options {
if opt == nil {
continue
}
switch opt.Name {
case "group":
group = opt.StringValue()
case "channel":
channel = opt.ChannelValue(s).ID
}
}
_, err := c.svc.SetChannelGains(ctx, group, channel)
if err != nil {
_ = s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
Type: discordgo.InteractionResponseChannelMessageWithSource,
Data: &discordgo.InteractionResponseData{
Content: messageFromError(err),
},
})
return
}
_ = s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
Type: discordgo.InteractionResponseChannelMessageWithSource,
Data: &discordgo.InteractionResponseData{
Content: "group has been successfully updated",
},
})
}
func (c *groupCommand) handleSetChannelLosses(s *discordgo.Session, i *discordgo.InteractionCreate) {
ctx := context.Background()
group := ""
channel := ""
for _, opt := range i.ApplicationCommandData().Options[0].Options[0].Options {
if opt == nil {
continue
}
switch opt.Name {
case "group":
group = opt.StringValue()
case "channel":
channel = opt.ChannelValue(s).ID
}
}
_, err := c.svc.SetChannelLosses(ctx, group, channel)
if err != nil {
_ = s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
Type: discordgo.InteractionResponseChannelMessageWithSource,
Data: &discordgo.InteractionResponseData{
Content: messageFromError(err),
},
})
return
}
_ = s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
Type: discordgo.InteractionResponseChannelMessageWithSource,
Data: &discordgo.InteractionResponseData{
Content: "group has been successfully updated",
},
})
}
func buildGroupListDescription(groups []domain.Group) string { func buildGroupListDescription(groups []domain.Group) string {
description := "**ID** - **Version** - **Server**" description := "**ID** - **Version** - **Server**"
for i, g := range groups { for i, g := range groups {

View File

@ -8,8 +8,8 @@ import (
type Group struct { type Group struct {
ID string ID string
ServerID string // Discord server ID ServerID string // Discord server ID
ChannelGainedVillages string ChannelGains string
ChannelLostVillages string ChannelLosses string
ServerKey string // Tribal Wars server key ServerKey string // Tribal Wars server key
VersionCode string VersionCode string
CreatedAt time.Time CreatedAt time.Time
@ -19,11 +19,11 @@ type CreateGroupParams struct {
serverID string serverID string
serverKey string serverKey string
versionCode string versionCode string
channelGainedVillages string channelGains string
channelLostVillages string channelLosses string
} }
func NewCreateGroupParams(serverID, versionCode, serverKey, channelGainedVillages, channelLostVillages string) (CreateGroupParams, error) { func NewCreateGroupParams(serverID, versionCode, serverKey, channelGains, channelLosses string) (CreateGroupParams, error) {
if serverID == "" { if serverID == "" {
return CreateGroupParams{}, RequiredError{ return CreateGroupParams{}, RequiredError{
Field: "ServerID", Field: "ServerID",
@ -46,8 +46,8 @@ func NewCreateGroupParams(serverID, versionCode, serverKey, channelGainedVillage
serverID: serverID, serverID: serverID,
serverKey: serverKey, serverKey: serverKey,
versionCode: versionCode, versionCode: versionCode,
channelGainedVillages: channelGainedVillages, channelGains: channelGains,
channelLostVillages: channelLostVillages, channelLosses: channelLosses,
}, nil }, nil
} }
@ -63,24 +63,24 @@ func (c CreateGroupParams) ServerKey() string {
return c.serverKey return c.serverKey
} }
func (c CreateGroupParams) ChannelGainedVillages() string { func (c CreateGroupParams) ChannelGains() string {
return c.channelGainedVillages return c.channelGains
} }
func (c CreateGroupParams) ChannelLostVillages() string { func (c CreateGroupParams) ChannelLosses() string {
return c.channelLostVillages return c.channelLosses
} }
type UpdateGroupParams struct { type UpdateGroupParams struct {
ChannelGainedVillages NullString ChannelGains NullString
ChannelLostVillages NullString ChannelLosses NullString
ServerKey NullString ServerKey NullString
VersionCode NullString VersionCode NullString
} }
func (u UpdateGroupParams) IsZero() bool { func (u UpdateGroupParams) IsZero() bool {
return !u.ChannelGainedVillages.Valid && return !u.ChannelGains.Valid &&
!u.ChannelLostVillages.Valid && !u.ChannelLosses.Valid &&
!u.VersionCode.Valid && !u.VersionCode.Valid &&
!u.ServerKey.Valid !u.ServerKey.Valid
} }

View File

@ -17,8 +17,8 @@ func TestNewCreateGroupParams(t *testing.T) {
serverID string serverID string
versionCode string versionCode string
serverKey string serverKey string
channelGainedVillages string channelGains string
channelLostVillages string channelLosses string
err error err error
}{ }{
{ {
@ -26,8 +26,8 @@ func TestNewCreateGroupParams(t *testing.T) {
serverID: "123441", serverID: "123441",
versionCode: "en", versionCode: "en",
serverKey: "en113", serverKey: "en113",
channelGainedVillages: "1234", channelGains: "1234",
channelLostVillages: "1234", channelLosses: "1234",
err: nil, err: nil,
}, },
{ {
@ -61,8 +61,8 @@ func TestNewCreateGroupParams(t *testing.T) {
tt.serverID, tt.serverID,
tt.versionCode, tt.versionCode,
tt.serverKey, tt.serverKey,
tt.channelGainedVillages, tt.channelGains,
tt.channelLostVillages, tt.channelLosses,
) )
if tt.err != nil { if tt.err != nil {
assert.ErrorIs(t, err, tt.err) assert.ErrorIs(t, err, tt.err)
@ -73,8 +73,8 @@ func TestNewCreateGroupParams(t *testing.T) {
assert.Equal(t, tt.serverID, res.ServerID()) assert.Equal(t, tt.serverID, res.ServerID())
assert.Equal(t, tt.serverKey, res.ServerKey()) assert.Equal(t, tt.serverKey, res.ServerKey())
assert.Equal(t, tt.versionCode, res.VersionCode()) assert.Equal(t, tt.versionCode, res.VersionCode())
assert.Equal(t, tt.channelGainedVillages, res.ChannelGainedVillages()) assert.Equal(t, tt.channelGains, res.ChannelGains())
assert.Equal(t, tt.channelLostVillages, res.ChannelLostVillages()) assert.Equal(t, tt.channelLosses, res.ChannelLosses())
}) })
} }
} }
@ -90,11 +90,11 @@ func TestUpdateGroupParams_IsZero(t *testing.T) {
{ {
name: "OK: all", name: "OK: all",
params: domain.UpdateGroupParams{ params: domain.UpdateGroupParams{
ChannelGainedVillages: domain.NullString{ ChannelGains: domain.NullString{
String: "123", String: "123",
Valid: true, Valid: true,
}, },
ChannelLostVillages: domain.NullString{ ChannelLosses: domain.NullString{
String: "123", String: "123",
Valid: true, Valid: true,
}, },
@ -110,9 +110,9 @@ func TestUpdateGroupParams_IsZero(t *testing.T) {
output: false, output: false,
}, },
{ {
name: "OK: ChannelGainedVillages", name: "OK: ChannelGains",
params: domain.UpdateGroupParams{ params: domain.UpdateGroupParams{
ChannelGainedVillages: domain.NullString{ ChannelGains: domain.NullString{
String: "123", String: "123",
Valid: true, Valid: true,
}, },
@ -120,9 +120,9 @@ func TestUpdateGroupParams_IsZero(t *testing.T) {
output: false, output: false,
}, },
{ {
name: "OK: ChannelLostVillages", name: "OK: ChannelLosses",
params: domain.UpdateGroupParams{ params: domain.UpdateGroupParams{
ChannelLostVillages: domain.NullString{ ChannelLosses: domain.NullString{
String: "123", String: "123",
Valid: true, Valid: true,
}, },

View File

@ -93,6 +93,32 @@ func (g *Group) SetTWServer(ctx context.Context, id, versionCode, serverKey stri
return group, nil return group, nil
} }
func (g *Group) SetChannelGains(ctx context.Context, id, channel string) (domain.Group, error) {
group, err := g.repo.UpdateByID(ctx, id, domain.UpdateGroupParams{
ChannelGains: domain.NullString{
String: channel,
Valid: true,
},
})
if err != nil {
return domain.Group{}, fmt.Errorf("GroupRepository.UpdateByID: %w", err)
}
return group, nil
}
func (g *Group) SetChannelLosses(ctx context.Context, id, channel string) (domain.Group, error) {
group, err := g.repo.UpdateByID(ctx, id, domain.UpdateGroupParams{
ChannelLosses: domain.NullString{
String: channel,
Valid: true,
},
})
if err != nil {
return domain.Group{}, fmt.Errorf("GroupRepository.UpdateByID: %w", err)
}
return group, nil
}
func (g *Group) List(ctx context.Context, params domain.ListGroupsParams) ([]domain.Group, error) { func (g *Group) List(ctx context.Context, params domain.ListGroupsParams) ([]domain.Group, error) {
groups, err := g.repo.List(ctx, params) groups, err := g.repo.List(ctx, params)
if err != nil { if err != nil {

View File

@ -35,8 +35,8 @@ func TestGroup_Create(t *testing.T) {
return domain.Group{ return domain.Group{
ID: uuid.NewString(), ID: uuid.NewString(),
ServerID: p.ServerID(), ServerID: p.ServerID(),
ChannelGainedVillages: p.ChannelGainedVillages(), ChannelGains: p.ChannelGains(),
ChannelLostVillages: p.ChannelLostVillages(), ChannelLosses: p.ChannelLosses(),
ServerKey: p.ServerKey(), ServerKey: p.ServerKey(),
VersionCode: p.VersionCode(), VersionCode: p.VersionCode(),
CreatedAt: time.Now(), CreatedAt: time.Now(),
@ -59,8 +59,8 @@ func TestGroup_Create(t *testing.T) {
assert.Equal(t, params.ServerID(), g.ServerID) assert.Equal(t, params.ServerID(), g.ServerID)
assert.Equal(t, params.ServerKey(), g.ServerKey) assert.Equal(t, params.ServerKey(), g.ServerKey)
assert.Equal(t, params.VersionCode(), g.VersionCode) assert.Equal(t, params.VersionCode(), g.VersionCode)
assert.Equal(t, params.ChannelGainedVillages(), g.ChannelGainedVillages) assert.Equal(t, params.ChannelGains(), g.ChannelGains)
assert.Equal(t, params.ChannelLostVillages(), g.ChannelLostVillages) assert.Equal(t, params.ChannelLosses(), g.ChannelLosses)
assert.NotEmpty(t, g.CreatedAt) assert.NotEmpty(t, g.CreatedAt)
}) })
@ -141,8 +141,8 @@ func TestGroup_SetTWServer(t *testing.T) {
return domain.Group{ return domain.Group{
ID: id, ID: id,
ServerID: uuid.NewString(), ServerID: uuid.NewString(),
ChannelGainedVillages: p.ChannelGainedVillages.String, ChannelGains: p.ChannelGains.String,
ChannelLostVillages: p.ChannelLostVillages.String, ChannelLosses: p.ChannelLosses.String,
ServerKey: p.ServerKey.String, ServerKey: p.ServerKey.String,
VersionCode: p.VersionCode.String, VersionCode: p.VersionCode.String,
CreatedAt: time.Now(), CreatedAt: time.Now(),