feat(assessment): assign the demonstration category and keep result history
This commit is contained in:
1 parent
b3c6dc870b
commit
8277133712
61 files changed
+4338
-268
No files matched your search
@@ -227,25 +227,41 @@ func TestDecideAssessmentCategoryIsDefaultOffEvenWithReviewedSource(t *testing.T
|
||||
}
|
||||
}
|
||||
|
||||
func TestSyntheticCategoryPolicyRequiresTheCompleteAcceptedAssessmentPolicy(t *testing.T) {
|
||||
accepted := DemoProductPolicyV2().Assessment
|
||||
if !sameAssessmentPolicy(accepted, DemoProductPolicyV2().Assessment) {
|
||||
t.Fatal("sameAssessmentPolicy(accepted) = false, want exact accepted policy")
|
||||
func categoryTestPolicyVersion(t *testing.T, policy ProductPolicy, version int32) PolicyVersion {
|
||||
t.Helper()
|
||||
draft, err := NewPolicyVersionDraft(NewPolicyVersionDraftInput{
|
||||
Key: ProductPolicyKey, Kind: PolicyKindDemo, Author: DemoPolicySeedAuthor,
|
||||
EffectiveAt: testPolicyEffectiveAt, Policy: policy,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("NewPolicyVersionDraft() error = %v", err)
|
||||
}
|
||||
changed := DemoProductPolicyV2().Assessment
|
||||
changed.StopRule.SeedItems++
|
||||
if sameAssessmentPolicy(changed, accepted) {
|
||||
t.Fatal("sameAssessmentPolicy(changed stop rule) = true, want false")
|
||||
numbered, err := draft.WithVersion(version)
|
||||
if err != nil {
|
||||
t.Fatalf("WithVersion() error = %v", err)
|
||||
}
|
||||
changed = DemoProductPolicyV2().Assessment
|
||||
changed.Attempt.IdleTimeoutSeconds++
|
||||
if sameAssessmentPolicy(changed, accepted) {
|
||||
t.Fatal("sameAssessmentPolicy(changed session settings) = true, want false")
|
||||
return mustRestore(t, storedFrom(numbered))
|
||||
}
|
||||
|
||||
func TestSyntheticCategoryPolicyIsAnyCompleteDemoBasicPolicyWithItsOwnThreshold(t *testing.T) {
|
||||
if err := ValidateSyntheticCategoryPolicy(testCategoryPolicyVersion(t)); err != nil {
|
||||
t.Fatalf("ValidateSyntheticCategoryPolicy(demo v2) error = %v", err)
|
||||
}
|
||||
changed = DemoProductPolicyV2().Assessment
|
||||
changed.Training = nil
|
||||
if sameAssessmentPolicy(changed, accepted) {
|
||||
t.Fatal("sameAssessmentPolicy(missing training settings) = true, want false")
|
||||
stricter := DemoProductPolicyV2()
|
||||
stricter.Assessment.Attempt.BasicPassMark = 9000
|
||||
if err := ValidateSyntheticCategoryPolicy(categoryTestPolicyVersion(t, stricter, 3)); err != nil {
|
||||
t.Fatalf("ValidateSyntheticCategoryPolicy(pass mark 9000) error = %v, want the policy's own threshold accepted", err)
|
||||
}
|
||||
if err := ValidateSyntheticCategoryPolicy(PolicyVersion{}); !errors.Is(err, ErrInvalidAssessmentCategory) {
|
||||
t.Fatalf("ValidateSyntheticCategoryPolicy(zero) error = %v, want invalid category", err)
|
||||
}
|
||||
if err := ValidateSyntheticCategoryPolicy(categoryTestPolicyVersion(t, DemoProductPolicyV1(), 1)); !errors.Is(err, ErrInvalidAssessmentCategory) {
|
||||
t.Fatalf("ValidateSyntheticCategoryPolicy(no attempt settings) error = %v, want invalid category", err)
|
||||
}
|
||||
noTraining := DemoProductPolicyV2()
|
||||
noTraining.Assessment.Training = nil
|
||||
if err := ValidateSyntheticCategoryPolicy(categoryTestPolicyVersion(t, noTraining, 4)); !errors.Is(err, ErrInvalidAssessmentCategory) {
|
||||
t.Fatalf("ValidateSyntheticCategoryPolicy(no training settings) error = %v, want invalid category", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user