mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender.git
synced 2025-08-04 18:59:13 +02:00
fix:#40 added test for remove empty courses and fix bug in function
This commit is contained in:
39
backend/service/events/courseService_test.go
Normal file
39
backend/service/events/courseService_test.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package events
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_removeEmptyCourses(t *testing.T) {
|
||||
type args struct {
|
||||
courses []string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want []string
|
||||
}{
|
||||
{
|
||||
name: "Test remove empty courses",
|
||||
args: args{
|
||||
courses: []string{"", "test", "test2", ""},
|
||||
},
|
||||
want: []string{"test", "test2"},
|
||||
},
|
||||
{
|
||||
name: "Test remove empty courses",
|
||||
args: args{
|
||||
courses: []string{"", "test", "test2", "", "test3"},
|
||||
},
|
||||
want: []string{"test", "test2", "test3"},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := removeEmptyCourses(tt.args.courses); !reflect.DeepEqual(got, tt.want) {
|
||||
t.Errorf("removeEmptyCourses() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user