fix:#53 added empty events check

This commit is contained in:
Elmar Kresse
2024-04-15 21:44:37 +02:00
parent f92fddb0d2
commit bad94d86fa
2 changed files with 29 additions and 18 deletions

View File

@@ -55,6 +55,8 @@ func ClearFeeds(db *daos.Dao, months int, clock localTime.Clock) {
func CombineEventsInFeed(events model.Events) model.Events {
// Combine events with the same name, start, end and course
// check if there are events
if len(events) > 0 {
combinedEvents := model.Events{events[0]}
for i := 1; i < len(events); i++ {
@@ -79,6 +81,8 @@ func CombineEventsInFeed(events model.Events) model.Events {
}
return combinedEvents
}
return model.Events{}
}
func addNotesIfAlreadyRoomsAdded(events model.Events, combinedEvents model.Events, index2 int, index1 int) string {
// check if combinedEvents[index2].Rooms string contains comma "," &#44

View File

@@ -182,6 +182,13 @@ func TestCombineEventsInFeed(t *testing.T) {
},
},
},
{
name: "NoEventsInFeed",
args: args{
events: model.Events{},
},
want: model.Events{},
},
}
for _, tt := range testCases {
t.Run(tt.name, func(t *testing.T) {