Files

49 lines
2.1 KiB
Go

package v1
import (
"testing"
"time"
"github.com/google/uuid"
"lincodex/backend/internal/adapter/primary/http/api"
"lincodex/backend/internal/domain"
"lincodex/backend/internal/usecase/profile"
)
func TestCandidateProfileResponseCarriesConfirmedCategoriesWithTheirBasis(t *testing.T) {
userID := uuid.New()
saved, err := domain.EmptyCandidateProfile(userID)
if err != nil {
t.Fatalf("EmptyCandidateProfile() error = %v", err)
}
assignedAt := time.Date(2026, time.October, 8, 10, 30, 0, 0, time.UTC)
attemptID := uuid.New()
category, err := domain.RestoreCandidateAssessmentCategory(domain.CandidateAssessmentCategorySnapshot{
CandidateID: userID, Specialization: domain.SpecializationBackend, Grade: domain.GradeJunior,
SourceAttemptID: domain.AssessmentAttemptID(attemptID), SourceReviewID: uuid.New(),
ProductPolicyVersionID: domain.PolicyVersionID(uuid.New()), ProductPolicyVersion: 1,
OpeningID: uuid.New(), OpeningManifestHash: [32]byte{1},
Source: domain.AssessmentCategorySourceSyntheticDemo, CalibrationStatus: domain.AssessmentCategoryCalibrationUncalibrated,
AssignedAt: assignedAt,
})
if err != nil {
t.Fatalf("RestoreCandidateAssessmentCategory() error = %v", err)
}
response := candidateProfileResponse(profile.View{Profile: saved, ConfirmedCategories: []domain.CandidateAssessmentCategory{category}})
if len(response.ConfirmedCategories) != 1 {
t.Fatalf("confirmed_categories = %+v, want one category", response.ConfirmedCategories)
}
got := response.ConfirmedCategories[0]
if got.Specialization != api.SpecializationCodeBackend || got.Grade != api.GradeCodeJunior ||
got.Basis != api.EvidenceBasisSyntheticDemo || got.AttemptID != attemptID || time.Time(got.ConfirmedAt) != assignedAt {
t.Fatalf("confirmed category = %+v, want backend junior from attempt %s with basis synthetic_demo", got, attemptID)
}
empty := candidateProfileResponse(profile.View{Profile: saved})
if empty.ConfirmedCategories == nil || len(empty.ConfirmedCategories) != 0 {
t.Fatalf("confirmed_categories of an empty view = %#v, want an empty list", empty.ConfirmedCategories)
}
}