diff --git a/services/data-manager/service/db/dbEvents.go b/services/data-manager/service/db/dbEvents.go index 4d43826..5612683 100644 --- a/services/data-manager/service/db/dbEvents.go +++ b/services/data-manager/service/db/dbEvents.go @@ -194,7 +194,7 @@ func NewEvent(collection *core.Collection, event model.Event) (*Event, error) { ev.SetBookedAt(event.BookedAt) ev.SetCourse(event.Course) ev.SetSemester(event.Semester) - ev.SetUUID(uuid.NewString()) + ev.SetUUID(event.UUID) return ev, nil } diff --git a/services/data-manager/service/fetch/v2/fetcher_test.go b/services/data-manager/service/fetch/v2/fetcher_test.go index a9f901a..b4f7328 100644 --- a/services/data-manager/service/fetch/v2/fetcher_test.go +++ b/services/data-manager/service/fetch/v2/fetcher_test.go @@ -97,3 +97,79 @@ func TestSwitchNameAndNotesForExam(t *testing.T) { }) } } + +func Test_generateUUIDs(t *testing.T) { + type args struct { + events []model.Event + } + tests := []struct { + name string + args args + want []model.Event + }{ + { + name: "generate UUIDs for events", + args: args{ + events: []model.Event{ + { + EventType: "Vorlesung", + Name: "Computer Vision II", + Course: "Computer Vision", + UUID: "", + }, + { + EventType: "Pruefung", + Name: "C169 Digitale Bildverarbeitung MIM & INM 3. FS (wpf)", + Course: "23INM", + UUID: "", + }, + { + EventType: "Vorlesung", + Name: "C398 Visualisierung in NW und Technik IN-M & MI-M 2. FS (wpf)", + Course: "24INM", + UUID: "", + }, + { + EventType: "Vorlesung", + Name: "M947 Fluidenergiemaschinen EGB (pf) & MBB & SGB (wpf) 4.FS", + Course: "23EGB-EGTa", + UUID: "", + }, + }, + }, + want: []model.Event{ + { + EventType: "Vorlesung", + Name: "Computer Vision II", + Course: "Computer Vision", + UUID: "8ddd913c-27f0-58b2-be17-e50f2851d482", + }, + { + EventType: "Pruefung", + Name: "C169 Digitale Bildverarbeitung MIM & INM 3. FS (wpf)", + Course: "23INM", + UUID: "2a35348d-63ce-511c-8580-893321d104b9", + }, + { + EventType: "Vorlesung", + Name: "C398 Visualisierung in NW und Technik IN-M & MI-M 2. FS (wpf)", + Course: "24INM", + UUID: "6051ebd9-dd2b-5646-82c4-091667f414ee", + }, + { + EventType: "Vorlesung", + Name: "M947 Fluidenergiemaschinen EGB (pf) & MBB & SGB (wpf) 4.FS", + Course: "23EGB-EGTa", + UUID: "736764e1-fa78-5195-8280-76c996dc8b47", + }, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := generateUUIDs(tt.args.events); !reflect.DeepEqual(got, tt.want) { + t.Errorf("generateUUIDs() = %v, want %v", got, tt.want) + } + }) + } +}