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>
45 lines
1.1 KiB
Go
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)
|
|
}
|
|
}
|
|
}
|