mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender.git
synced 2025-08-02 17:59:14 +02:00
126 lines
2.6 KiB
Go
126 lines
2.6 KiB
Go
package room
|
|
|
|
import (
|
|
"htwkalender/model"
|
|
"reflect"
|
|
"testing"
|
|
|
|
"github.com/pocketbase/pocketbase/tools/types"
|
|
)
|
|
|
|
func Test_anonymizeRooms(t *testing.T) {
|
|
type args struct {
|
|
events []model.Event
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
args args
|
|
want []model.AnonymizedEventDTO
|
|
}{
|
|
{
|
|
name: "anonymize single event",
|
|
args: args{
|
|
events: []model.Event{
|
|
{
|
|
UUID: "testUUID",
|
|
Day: "Montag",
|
|
Week: "52",
|
|
Start: types.DateTime{},
|
|
End: types.DateTime{},
|
|
Name: "Secret",
|
|
EventType: "V",
|
|
Prof: "Prof. Dr. Secret",
|
|
Rooms: "Room",
|
|
Notes: "Secret",
|
|
BookedAt: "Secret",
|
|
Course: "42INM-3",
|
|
Semester: "ws",
|
|
Compulsory: "p",
|
|
},
|
|
},
|
|
},
|
|
want: []model.AnonymizedEventDTO{
|
|
{
|
|
Day: "Montag",
|
|
Week: "52",
|
|
Start: types.DateTime{},
|
|
End: types.DateTime{},
|
|
Rooms: "Room",
|
|
Free: false,
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "anonymize empty list",
|
|
args: args{
|
|
events: []model.Event{},
|
|
},
|
|
want: []model.AnonymizedEventDTO{},
|
|
},
|
|
{
|
|
name: "anonymize multiple events",
|
|
args: args{
|
|
events: []model.Event{
|
|
{
|
|
UUID: "testUUID1",
|
|
Day: "Montag",
|
|
Week: "51",
|
|
Start: types.DateTime{},
|
|
End: types.DateTime{},
|
|
Name: "Incognito",
|
|
EventType: "V",
|
|
Prof: "Prof. Dr. Incognito",
|
|
Rooms: "Room",
|
|
Notes: "Incognito",
|
|
BookedAt: "Incognito",
|
|
Course: "69INM-2",
|
|
Semester: "sose",
|
|
Compulsory: "p",
|
|
},
|
|
{
|
|
UUID: "testUUID2",
|
|
Day: "Dienstag",
|
|
Week: "52",
|
|
Start: types.DateTime{},
|
|
End: types.DateTime{},
|
|
Name: "Private",
|
|
EventType: "S",
|
|
Prof: "Prof.In. Dr.-Ing. Private",
|
|
Rooms: "Room",
|
|
Notes: "Private",
|
|
BookedAt: "Private",
|
|
Course: "42MIM-3",
|
|
Semester: "ws",
|
|
Compulsory: "w",
|
|
},
|
|
},
|
|
},
|
|
want: []model.AnonymizedEventDTO{
|
|
{
|
|
Day: "Montag",
|
|
Week: "51",
|
|
Start: types.DateTime{},
|
|
End: types.DateTime{},
|
|
Rooms: "Room",
|
|
Free: false,
|
|
},
|
|
{
|
|
Day: "Dienstag",
|
|
Week: "52",
|
|
Start: types.DateTime{},
|
|
End: types.DateTime{},
|
|
Rooms: "Room",
|
|
Free: false,
|
|
},
|
|
},
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if got := anonymizeRooms(tt.args.events); !reflect.DeepEqual(got, tt.want) {
|
|
t.Errorf("anonymizeRooms() = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|