RezinaLMS-BackEnd/internal/domain/practice_parent_kind_test.go
Yared Yemane 218c09c904 feat: add per-parent practice unlink endpoints for LMS and exam-prep
Adds DELETE /practices/:id/parents/:parentKind/:parentId and exam-prep equivalent so admins can remove one location link without replacing the full parents array. Includes admin panel integration guide and parent kind parse tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-02 04:21:30 -07:00

45 lines
1.1 KiB
Go

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