package functions

import (
	"htwkalender/data-manager/model"
	"reflect"
	"testing"
)

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)
			}
		})
	}
}
