package domain import "testing" func TestParsePracticeParentKind(t *testing.T) { tests := []struct { raw string want ParentKind ok bool }{ {"COURSE", ParentKindCourse, true}, {"course", ParentKindCourse, true}, {" MODULE ", ParentKindModule, true}, {"LESSON", ParentKindLesson, true}, {"UNIT", "", false}, {"", "", false}, } for _, tc := range tests { got, ok := ParsePracticeParentKind(tc.raw) if ok != tc.ok || got != tc.want { t.Fatalf("ParsePracticeParentKind(%q) = (%q, %v), want (%q, %v)", tc.raw, got, ok, tc.want, tc.ok) } } } func TestParseExamPrepParentKind(t *testing.T) { tests := []struct { raw string want ExamPrepParentKind ok bool }{ {"CATALOG_COURSE", ExamPrepParentKindCatalogCourse, true}, {"catalog_course", ExamPrepParentKindCatalogCourse, true}, {"UNIT", ExamPrepParentKindUnit, true}, {"LESSON", ExamPrepParentKindLesson, true}, {"MODULE", "", false}, } for _, tc := range tests { got, ok := ParseExamPrepParentKind(tc.raw) if ok != tc.ok || got != tc.want { t.Fatalf("ParseExamPrepParentKind(%q) = (%q, %v), want (%q, %v)", tc.raw, got, ok, tc.want, tc.ok) } } }