diff --git a/backend/service/fetch/v2/fetcher_test.go b/backend/service/fetch/v2/fetcher_test.go new file mode 100644 index 0000000..c0acff6 --- /dev/null +++ b/backend/service/fetch/v2/fetcher_test.go @@ -0,0 +1,83 @@ +package v2 + +import ( + "htwkalender/model" + "reflect" + "testing" +) + +func Test_switchNameAndNotesForExam(t *testing.T) { + type args struct { + events []model.Event + } + tests := []struct { + name string + args args + want []model.Event + }{ + { + name: "switch name and notes for exam", + args: args{ + events: []model.Event{ + { + EventType: "Pruefung", + Name: "Prüfungen FING/EIT WiSe (pruefungsamt.fing-eit@htwk-leipzig.de)", + Notes: "Computer Vision II - Räume/Zeit unter Vorbehalt- (Raum W111.1)", + }, + }, + }, + want: []model.Event{ + { + EventType: "Pruefung", + Name: "Computer Vision II - Räume/Zeit unter Vorbehalt- (Raum W111.1)", + Notes: "Prüfungen FING/EIT WiSe (pruefungsamt.fing-eit@htwk-leipzig.de)", + }, + }, + }, + { + name: "dont switch name and notes for exam", + args: args{ + events: []model.Event{ + { + EventType: "Pruefung", + Name: "i054 Umweltschutz und Recycling DPB & VNB 7.FS (wpf)", + Notes: "Prüfung", + }, + }, + }, + want: []model.Event{ + { + EventType: "Pruefung", + Notes: "Prüfung", + Name: "i054 Umweltschutz und Recycling DPB & VNB 7.FS (wpf)", + }, + }, + }, + { + name: "dont switch name and notes for exam", + args: args{ + events: []model.Event{ + { + EventType: "Pruefung", + Name: "Prüfungen FING/ME WiSe (pruefungsamt.fing-me@htwk-leipzig.de)", + Notes: "", + }, + }, + }, + want: []model.Event{ + { + EventType: "Pruefung", + Notes: "", + Name: "Prüfungen FING/ME WiSe (pruefungsamt.fing-me@htwk-leipzig.de)", + }, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := switchNameAndNotesForExam(tt.args.events); !reflect.DeepEqual(got, tt.want) { + t.Errorf("switchNameAndNotesForExam() = %v, want %v", got, tt.want) + } + }) + } +}