Contract codes now use the agent.* values, and runtime can emit structured logs without changing results when no logger is configured. Co-authored-by: Cursor <cursoragent@cursor.com>
35 lines
1.2 KiB
Go
35 lines
1.2 KiB
Go
package catalogcheck
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"agent-native/contract"
|
|
"error-code-system/errcode"
|
|
)
|
|
|
|
// 常量取值必须与错误码库种子码相同。旧短字符串只作为错误码库里的别名存在。
|
|
func TestContractCodesMatchCatalog(t *testing.T) {
|
|
pairs := []struct {
|
|
got contract.ErrorCode
|
|
want errcode.Code
|
|
}{
|
|
{contract.ErrCanceled, errcode.AgentCanceled},
|
|
{contract.ErrDeadlineExceeded, errcode.AgentDeadlineExceeded},
|
|
{contract.ErrBudgetExceeded, errcode.AgentBudgetExceeded},
|
|
{contract.ErrProviderUnavailable, errcode.AgentProviderUnavailable},
|
|
{contract.ErrProviderRejected, errcode.AgentProviderRejected},
|
|
{contract.ErrToolRejected, errcode.AgentToolRejected},
|
|
{contract.ErrPathOutsideWorkspace, errcode.AgentPathOutsideWorkspace},
|
|
{contract.ErrMissingCapability, errcode.AgentMissingCapability},
|
|
{contract.ErrMissingDeliverable, errcode.AgentMissingDeliverable},
|
|
{contract.ErrEmptyOutput, errcode.AgentEmptyOutput},
|
|
{contract.ErrUnknownOutcome, errcode.AgentUnknownOutcome},
|
|
{contract.ErrInternal, errcode.AgentInternal},
|
|
}
|
|
for _, pair := range pairs {
|
|
if string(pair.got) != string(pair.want) {
|
|
t.Errorf("contract %q != catalog %q", pair.got, pair.want)
|
|
}
|
|
}
|
|
}
|