refactor: tests - delete unnecessary nestings
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
99158e3410
commit
ac6330a3b1
|
@ -136,9 +136,6 @@ func TestGroup_Create(t *testing.T) {
|
||||||
func TestGroup_CleanUp(t *testing.T) {
|
func TestGroup_CleanUp(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
t.Run("OK", func(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
repo := &mock.FakeGroupRepository{}
|
repo := &mock.FakeGroupRepository{}
|
||||||
groupsWithDisabledNotifications := []domain.Group{
|
groupsWithDisabledNotifications := []domain.Group{
|
||||||
{
|
{
|
||||||
|
@ -293,5 +290,4 @@ func TestGroup_CleanUp(t *testing.T) {
|
||||||
|
|
||||||
require.Equal(t, 1, client.ListVersionsCallCount())
|
require.Equal(t, 1, client.ListVersionsCallCount())
|
||||||
require.Equal(t, 3, client.ListServersCallCount())
|
require.Equal(t, 3, client.ListServersCallCount())
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,9 +179,6 @@ func TestMonitor_Create(t *testing.T) {
|
||||||
func TestMonitor_List(t *testing.T) {
|
func TestMonitor_List(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
t.Run("OK", func(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
groupID := uuid.NewString()
|
groupID := uuid.NewString()
|
||||||
groupSvc := &mock.FakeGroupReader{}
|
groupSvc := &mock.FakeGroupReader{}
|
||||||
groupSvc.GetCalls(func(ctx context.Context, groupID, serverID string) (domain.Group, error) {
|
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, res[i].Monitor)
|
||||||
assert.Equal(t, m.TribeID, res[i].Tribe.ID)
|
assert.Equal(t, m.TribeID, res[i].Tribe.ID)
|
||||||
}
|
}
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMonitor_Execute(t *testing.T) {
|
func TestMonitor_Execute(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
t.Run("OK", func(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
client := &mock.FakeTWHelpClient{}
|
client := &mock.FakeTWHelpClient{}
|
||||||
villages := map[string][]twhelp.VillageMeta{
|
villages := map[string][]twhelp.VillageMeta{
|
||||||
"pl:pl181": {
|
"pl:pl181": {
|
||||||
|
@ -762,47 +755,46 @@ func TestMonitor_Execute(t *testing.T) {
|
||||||
Type: domain.EnnoblementNotificationTypeGain,
|
Type: domain.EnnoblementNotificationTypeGain,
|
||||||
ServerID: groups[0].ServerID,
|
ServerID: groups[0].ServerID,
|
||||||
ChannelID: groups[0].ChannelGains,
|
ChannelID: groups[0].ChannelGains,
|
||||||
Ennoblement: ennoblementToDomainModel(ennoblements["pl:pl181"][0]),
|
Ennoblement: newEnnoblement(ennoblements["pl:pl181"][0]),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Type: domain.EnnoblementNotificationTypeGain,
|
Type: domain.EnnoblementNotificationTypeGain,
|
||||||
ServerID: groups[0].ServerID,
|
ServerID: groups[0].ServerID,
|
||||||
ChannelID: groups[0].ChannelGains,
|
ChannelID: groups[0].ChannelGains,
|
||||||
Ennoblement: ennoblementToDomainModel(ennoblements["pl:pl181"][3]),
|
Ennoblement: newEnnoblement(ennoblements["pl:pl181"][3]),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Type: domain.EnnoblementNotificationTypeLoss,
|
Type: domain.EnnoblementNotificationTypeLoss,
|
||||||
ServerID: groups[1].ServerID,
|
ServerID: groups[1].ServerID,
|
||||||
ChannelID: groups[1].ChannelLosses,
|
ChannelID: groups[1].ChannelLosses,
|
||||||
Ennoblement: ennoblementToDomainModel(ennoblements["pl:pl181"][0]),
|
Ennoblement: newEnnoblement(ennoblements["pl:pl181"][0]),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Type: domain.EnnoblementNotificationTypeGain,
|
Type: domain.EnnoblementNotificationTypeGain,
|
||||||
ServerID: groups[2].ServerID,
|
ServerID: groups[2].ServerID,
|
||||||
ChannelID: groups[2].ChannelGains,
|
ChannelID: groups[2].ChannelGains,
|
||||||
Ennoblement: ennoblementToDomainModel(ennoblements["en:en130"][2]),
|
Ennoblement: newEnnoblement(ennoblements["en:en130"][2]),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Type: domain.EnnoblementNotificationTypeGain,
|
Type: domain.EnnoblementNotificationTypeGain,
|
||||||
ServerID: groups[4].ServerID,
|
ServerID: groups[4].ServerID,
|
||||||
ChannelID: groups[4].ChannelGains,
|
ChannelID: groups[4].ChannelGains,
|
||||||
Ennoblement: ennoblementToDomainModel(ennoblements["de:de200"][1]),
|
Ennoblement: newEnnoblement(ennoblements["de:de200"][1]),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Type: domain.EnnoblementNotificationTypeGain,
|
Type: domain.EnnoblementNotificationTypeGain,
|
||||||
ServerID: groups[4].ServerID,
|
ServerID: groups[4].ServerID,
|
||||||
ChannelID: groups[4].ChannelGains,
|
ChannelID: groups[4].ChannelGains,
|
||||||
Ennoblement: ennoblementToDomainModel(ennoblements["de:de200"][2]),
|
Ennoblement: newEnnoblement(ennoblements["de:de200"][2]),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
assert.Len(t, notifications, len(expectedNotifications))
|
assert.Len(t, notifications, len(expectedNotifications))
|
||||||
for _, n := range expectedNotifications {
|
for _, n := range expectedNotifications {
|
||||||
assert.Contains(t, notifications, n)
|
assert.Contains(t, notifications, n)
|
||||||
}
|
}
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func ennoblementToDomainModel(e twhelp.Ennoblement) domain.Ennoblement {
|
func newEnnoblement(e twhelp.Ennoblement) domain.Ennoblement {
|
||||||
return domain.Ennoblement{
|
return domain.Ennoblement{
|
||||||
ID: e.ID,
|
ID: e.ID,
|
||||||
Village: domain.VillageMeta(e.Village),
|
Village: domain.VillageMeta(e.Village),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user