fix(assessment): return confirmed categories with their basis and label demonstration categories
This commit is contained in:
1 parent
623d41b969
commit
d4903a3796
77 files changed
+1441
-288
No files matched your search
@@ -0,0 +1,35 @@
|
||||
package postgres
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"lincodex/backend/internal/domain"
|
||||
)
|
||||
|
||||
func TestPrivacyCohortConfirmedCategoriesCarryTheStoredBasis(t *testing.T) {
|
||||
categories, err := privacyCohortConfirmedCategories(`[{"specialization":"backend","grade":"junior","source":"synthetic_demo"}]`)
|
||||
if err != nil {
|
||||
t.Fatalf("privacyCohortConfirmedCategories() error = %v", err)
|
||||
}
|
||||
if len(categories) != 1 || categories[0].Specialization != domain.SpecializationBackend ||
|
||||
categories[0].Grade != domain.GradeJunior || categories[0].Basis != domain.AssessmentCategorySourceSyntheticDemo {
|
||||
t.Fatalf("categories = %+v, want the backend junior category with its synthetic basis", categories)
|
||||
}
|
||||
}
|
||||
|
||||
// A category whose basis is missing or unknown must not reach a card as if it
|
||||
// were a real confirmation, so the projection fails instead of guessing.
|
||||
func TestPrivacyCohortConfirmedCategoriesRejectAnUnknownBasis(t *testing.T) {
|
||||
for name, value := range map[string]string{
|
||||
"missing basis": `[{"specialization":"backend","grade":"junior"}]`,
|
||||
"unknown basis": `[{"specialization":"backend","grade":"junior","source":"real"}]`,
|
||||
"unknown property": `[{"specialization":"backend","grade":"junior","source":"synthetic_demo","score":9}]`,
|
||||
} {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
if _, err := privacyCohortConfirmedCategories(value); !errors.Is(err, domain.ErrInvalidCandidateViewSource) {
|
||||
t.Fatalf("privacyCohortConfirmedCategories() error = %v, want invalid candidate view source", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user