48 lines
1.4 KiB
Go
48 lines
1.4 KiB
Go
package chat
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"chat-agent-system/internal/ctxmgr"
|
|
"chat-agent-system/internal/intent"
|
|
)
|
|
|
|
// TestAllIntentsMappedToCategory 确保 intent/types.go 定义的全部意图常量都在 ctxmgr.IntentCategoryMap 中有确切分类映射
|
|
// 杜绝意图增加/重命名导致的分类漂移与野指针
|
|
func TestAllIntentsMappedToCategory(t *testing.T) {
|
|
allIntents := []intent.IntentType{
|
|
intent.IntentQueryProgress,
|
|
intent.IntentSupplementInfo,
|
|
intent.IntentAdvanceStage,
|
|
intent.IntentTriggerTask,
|
|
intent.IntentTriggerAdhocTask,
|
|
intent.IntentCasualChat,
|
|
intent.IntentDeclineExpectation,
|
|
intent.IntentDocGovClaim,
|
|
intent.IntentDocGovSubmitReview,
|
|
intent.IntentDocGovReviewApprove,
|
|
intent.IntentDocGovReviewReject,
|
|
intent.IntentDocGovFinalApprove,
|
|
intent.IntentDocGovFinalReject,
|
|
intent.IntentDocGovProposalDecide,
|
|
intent.IntentQueryRegulations,
|
|
intent.IntentQuerySimilarCases,
|
|
intent.IntentQueryUserRights,
|
|
intent.IntentQueryRejectReason,
|
|
intent.IntentConfirmAction,
|
|
intent.IntentExecuteStageAdvance,
|
|
intent.IntentSecurityForbidden,
|
|
}
|
|
|
|
for _, it := range allIntents {
|
|
cat, ok := ctxmgr.IntentCategoryMap[string(it)]
|
|
if !ok {
|
|
t.Errorf("Intent %q is missing from ctxmgr.IntentCategoryMap", it)
|
|
continue
|
|
}
|
|
if cat == "" || cat == ctxmgr.CategoryUncategorized {
|
|
t.Errorf("Intent %q maps to empty or uncategorized category %q", it, cat)
|
|
}
|
|
}
|
|
}
|