ariadne/internal/domain/failure/failure_test.go
2026-07-24 05:45:04 +09:00

47 lines
1.1 KiB
Go

package failure
import (
"testing"
"time"
)
func TestFailureValidate(t *testing.T) {
t.Parallel()
executionFailure := Failure{
SchemaVersion: SchemaVersionV1,
Code: "IOP_EXECUTION_FAILED",
Stage: StageIOPExecution,
Message: "IOP returned an execution failure",
UserMessage: "분석 실행 중 오류가 발생했습니다.",
OccurredAt: time.Now(),
Causes: []Cause{
{
Code: "TRANSLATION_FAILED",
Stage: StageTranslation,
Message: "local translation model was unavailable",
},
},
}
if err := executionFailure.Validate(); err != nil {
t.Fatalf("Validate() error = %v", err)
}
}
func TestFailureValidateRejectsUnknownStage(t *testing.T) {
t.Parallel()
executionFailure := Failure{
SchemaVersion: SchemaVersionV1,
Code: "INVALID_STAGE",
Stage: "unknown",
Message: "invalid stage",
UserMessage: "처리 단계가 올바르지 않습니다.",
OccurredAt: time.Now(),
}
if err := executionFailure.Validate(); err == nil {
t.Fatal("Validate() expected a stage error")
}
}