mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender.git
synced 2025-08-03 02:09:15 +02:00
feat:#16 fixed contains with slices
This commit is contained in:
@@ -1,16 +1,14 @@
|
||||
package model
|
||||
|
||||
import "github.com/pocketbase/pocketbase/models"
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/models"
|
||||
"slices"
|
||||
)
|
||||
|
||||
type Events []Event
|
||||
|
||||
func (m Events) Contains(event Event) bool {
|
||||
for _, e := range m {
|
||||
if e.Equals(event) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
return slices.Contains(m, event)
|
||||
}
|
||||
|
||||
type Event struct {
|
||||
|
@@ -35,8 +35,8 @@ func TestEvents_Contains(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "two events with different values",
|
||||
m: Events{{Day: "test", Week: "test", Start: "test", End: "test", Name: "test", Course: "test", Prof: "test", Rooms: "test", EventType: "test"}, {Day: "test2", Week: "test2", Start: "test2", End: "test2", Name: "test2", Course: "test2", Prof: "test2", Rooms: "test2", EventType: "test2"}},
|
||||
args: args{event: Event{Day: "test3", Week: "test3", Start: "test3", End: "test3", Name: "test3", Course: "test3", Prof: "test3", Rooms: "test3", EventType: "test3"}},
|
||||
m: Events{{Day: "test", Week: "test", Start: "test", End: "test", Name: "test", Course: "test", Prof: "test", Rooms: "test", EventType: "test", UUID: "439ßu56rf8u9ijn4f4-2345345"}, {Day: "test2", Week: "test2", Start: "test2", End: "test2", Name: "test2", Course: "test2", Prof: "test2", Rooms: "test2", EventType: "test2", UUID: "432a39ßu545349ijn4f4-23dsa45"}},
|
||||
args: args{event: Event{Day: "test3", Week: "test3", Start: "test3", End: "test3", Name: "test3", Course: "test3", Prof: "test3", Rooms: "test3", EventType: "test3", UUID: "934mf43r34f-g68h7655tg3"}},
|
||||
want: false,
|
||||
},
|
||||
}
|
||||
|
Reference in New Issue
Block a user