-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors_test.go
More file actions
53 lines (45 loc) · 1.21 KB
/
Copy patherrors_test.go
File metadata and controls
53 lines (45 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package agentic
import (
"errors"
"fmt"
"testing"
)
func TestModelRetryError(t *testing.T) {
mr := &ModelRetry{Message: "try again"}
if mr.Error() != "try again" {
t.Errorf("expected %q, got %q", "try again", mr.Error())
}
}
func TestRetry(t *testing.T) {
mr := Retry("bad input")
if mr.Message != "bad input" {
t.Errorf("expected %q, got %q", "bad input", mr.Message)
}
}
func TestRetryf(t *testing.T) {
mr := Retryf("error %d: %s", 42, "not found")
expected := "error 42: not found"
if mr.Message != expected {
t.Errorf("expected %q, got %q", expected, mr.Message)
}
}
func TestIsModelRetry(t *testing.T) {
mr := Retry("retry me")
if !IsModelRetry(mr) {
t.Error("expected IsModelRetry to return true")
}
wrapped := fmt.Errorf("wrapped: %w", mr)
if !IsModelRetry(wrapped) {
t.Error("expected IsModelRetry to return true for wrapped error")
}
if IsModelRetry(errors.New("not a retry")) {
t.Error("expected IsModelRetry to return false for non-ModelRetry error")
}
}
func TestMaxIterationsError(t *testing.T) {
err := &MaxIterationsError{MaxIterations: 5}
expected := "agent reached maximum iterations (5)"
if err.Error() != expected {
t.Errorf("expected %q, got %q", expected, err.Error())
}
}