Files
ragflow/internal/handler/error_test.go
Jack 10c00a9614 Feat: add built in DSL file API (#17003)
### Summary

1. list and get by id API for builtin DSL
2. add DSL default component param values validation
3. remove all hard code keys for parser config
2026-07-18 11:00:08 +08:00

44 lines
983 B
Go

package handler
import (
"testing"
"ragflow/internal/common"
"ragflow/internal/service"
)
func TestIngestionTaskErrorCode(t *testing.T) {
testCases := []struct {
name string
err error
want common.ErrorCode
}{
{
name: "invalid transition",
err: &service.InvalidTaskTransitionError{TaskID: "task-1", From: common.CREATED, To: common.COMPLETED},
want: common.CodeConflict,
},
{
name: "status conflict",
err: &service.TaskStatusConflictError{TaskID: "task-1", ExpectedFrom: common.CREATED, AttemptedTo: common.RUNNING, ActualCurrent: common.STOPPING},
want: common.CodeConflict,
},
{
name: "task not found",
err: common.ErrTaskNotFound,
want: common.CodeNotFound,
},
{
name: "fallback",
err: common.ErrInvalidToken,
want: common.CodeExceptionError,
},
}
for _, tc := range testCases {
if got := IngestionTaskErrorCode(tc.err); got != tc.want {
t.Fatalf("%s: got %d, want %d", tc.name, got, tc.want)
}
}
}