-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathactor_headers_test.go
More file actions
56 lines (45 loc) · 1.31 KB
/
actor_headers_test.go
File metadata and controls
56 lines (45 loc) · 1.31 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
54
55
56
package intercept
import (
"testing"
"github.com/google/uuid"
"github.com/stretchr/testify/require"
"github.com/coder/aibridge/context"
"github.com/coder/aibridge/recorder"
)
func TestNilActor(t *testing.T) {
t.Parallel()
require.Nil(t, ActorHeadersAsOpenAIOpts(nil))
require.Nil(t, ActorHeadersAsAnthropicOpts(nil))
}
func TestBasic(t *testing.T) {
t.Parallel()
actorID := uuid.NewString()
actor := &context.Actor{
ID: actorID,
}
// We can't peek inside since these opts require an internal type to apply onto.
// All we can do is check the length.
// See TestActorHeaders for an integration test.
oaiOpts := ActorHeadersAsOpenAIOpts(actor)
require.Len(t, oaiOpts, 1)
antOpts := ActorHeadersAsAnthropicOpts(actor)
require.Len(t, antOpts, 1)
}
func TestBasicAndMetadata(t *testing.T) {
t.Parallel()
actorID := uuid.NewString()
actor := &context.Actor{
ID: actorID,
Metadata: recorder.Metadata{
"This": "That",
"And": "The other",
},
}
// We can't peek inside since these opts require an internal type to apply onto.
// All we can do is check the length.
// See TestActorHeaders for an integration test.
oaiOpts := ActorHeadersAsOpenAIOpts(actor)
require.Len(t, oaiOpts, 1+len(actor.Metadata))
antOpts := ActorHeadersAsAnthropicOpts(actor)
require.Len(t, antOpts, 1+len(actor.Metadata))
}