refactor: tests - delete unnecessary nestings
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Dawid Wysokiński 2022-12-25 12:04:17 +01:00
parent 99158e3410
commit ac6330a3b1
Signed by: Kichiyaki
GPG Key ID: B5445E357FB8B892
2 changed files with 748 additions and 760 deletions

View File

@ -136,9 +136,6 @@ func TestGroup_Create(t *testing.T) {
func TestGroup_CleanUp(t *testing.T) {
t.Parallel()
t.Run("OK", func(t *testing.T) {
t.Parallel()
repo := &mock.FakeGroupRepository{}
groupsWithDisabledNotifications := []domain.Group{
{
@ -293,5 +290,4 @@ func TestGroup_CleanUp(t *testing.T) {
require.Equal(t, 1, client.ListVersionsCallCount())
require.Equal(t, 3, client.ListServersCallCount())
})
}

View File

@ -179,9 +179,6 @@ func TestMonitor_Create(t *testing.T) {
func TestMonitor_List(t *testing.T) {
t.Parallel()
t.Run("OK", func(t *testing.T) {
t.Parallel()
groupID := uuid.NewString()
groupSvc := &mock.FakeGroupReader{}
groupSvc.GetCalls(func(ctx context.Context, groupID, serverID string) (domain.Group, error) {
@ -232,15 +229,11 @@ func TestMonitor_List(t *testing.T) {
assert.Equal(t, m, res[i].Monitor)
assert.Equal(t, m.TribeID, res[i].Tribe.ID)
}
})
}
func TestMonitor_Execute(t *testing.T) {
t.Parallel()
t.Run("OK", func(t *testing.T) {
t.Parallel()
client := &mock.FakeTWHelpClient{}
villages := map[string][]twhelp.VillageMeta{
"pl:pl181": {
@ -762,47 +755,46 @@ func TestMonitor_Execute(t *testing.T) {
Type: domain.EnnoblementNotificationTypeGain,
ServerID: groups[0].ServerID,
ChannelID: groups[0].ChannelGains,
Ennoblement: ennoblementToDomainModel(ennoblements["pl:pl181"][0]),
Ennoblement: newEnnoblement(ennoblements["pl:pl181"][0]),
},
{
Type: domain.EnnoblementNotificationTypeGain,
ServerID: groups[0].ServerID,
ChannelID: groups[0].ChannelGains,
Ennoblement: ennoblementToDomainModel(ennoblements["pl:pl181"][3]),
Ennoblement: newEnnoblement(ennoblements["pl:pl181"][3]),
},
{
Type: domain.EnnoblementNotificationTypeLoss,
ServerID: groups[1].ServerID,
ChannelID: groups[1].ChannelLosses,
Ennoblement: ennoblementToDomainModel(ennoblements["pl:pl181"][0]),
Ennoblement: newEnnoblement(ennoblements["pl:pl181"][0]),
},
{
Type: domain.EnnoblementNotificationTypeGain,
ServerID: groups[2].ServerID,
ChannelID: groups[2].ChannelGains,
Ennoblement: ennoblementToDomainModel(ennoblements["en:en130"][2]),
Ennoblement: newEnnoblement(ennoblements["en:en130"][2]),
},
{
Type: domain.EnnoblementNotificationTypeGain,
ServerID: groups[4].ServerID,
ChannelID: groups[4].ChannelGains,
Ennoblement: ennoblementToDomainModel(ennoblements["de:de200"][1]),
Ennoblement: newEnnoblement(ennoblements["de:de200"][1]),
},
{
Type: domain.EnnoblementNotificationTypeGain,
ServerID: groups[4].ServerID,
ChannelID: groups[4].ChannelGains,
Ennoblement: ennoblementToDomainModel(ennoblements["de:de200"][2]),
Ennoblement: newEnnoblement(ennoblements["de:de200"][2]),
},
}
assert.Len(t, notifications, len(expectedNotifications))
for _, n := range expectedNotifications {
assert.Contains(t, notifications, n)
}
})
}
func ennoblementToDomainModel(e twhelp.Ennoblement) domain.Ennoblement {
func newEnnoblement(e twhelp.Ennoblement) domain.Ennoblement {
return domain.Ennoblement{
ID: e.ID,
Village: domain.VillageMeta(e.Village),