MCPcopy Index your code
hub / github.com/coder/coder / TestAIBridgeInterception

Function TestAIBridgeInterception

coderd/database/db2sdk/db2sdk_test.go:602–832  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

600}
601
602func TestAIBridgeInterception(t *testing.T) {
603 t.Parallel()
604
605 now := dbtime.Now()
606 interceptionID := uuid.New()
607 initiatorID := uuid.New()
608
609 cases := []struct {
610 name string
611 interception database.AIBridgeInterception
612 initiator database.VisibleUser
613 tokenUsages []database.AIBridgeTokenUsage
614 userPrompts []database.AIBridgeUserPrompt
615 toolUsages []database.AIBridgeToolUsage
616 expected codersdk.AIBridgeInterception
617 }{
618 {
619 name: "all_optional_values_set",
620 interception: database.AIBridgeInterception{
621 ID: interceptionID,
622 InitiatorID: initiatorID,
623 Provider: "anthropic",
624 Model: "claude-3-opus",
625 StartedAt: now,
626 Metadata: pqtype.NullRawMessage{
627 RawMessage: json.RawMessage(`{"key":"value"}`),
628 Valid: true,
629 },
630 EndedAt: sql.NullTime{
631 Time: now.Add(time.Minute),
632 Valid: true,
633 },
634 APIKeyID: sql.NullString{
635 String: "api-key-123",
636 Valid: true,
637 },
638 Client: sql.NullString{
639 String: "claude-code/1.0.0",
640 Valid: true,
641 },
642 },
643 initiator: database.VisibleUser{
644 ID: initiatorID,
645 Username: "testuser",
646 Name: "Test User",
647 AvatarURL: "https://example.com/avatar.png",
648 },
649 tokenUsages: []database.AIBridgeTokenUsage{
650 {
651 ID: uuid.New(),
652 InterceptionID: interceptionID,
653 ProviderResponseID: "resp-123",
654 InputTokens: 100,
655 OutputTokens: 200,
656 CacheReadInputTokens: 50,
657 CacheWriteInputTokens: 10,
658 Metadata: pqtype.NullRawMessage{
659 RawMessage: json.RawMessage(`{"cache":"hit"}`),

Callers

nothing calls this directly

Calls 7

NowFunction · 0.92
AIBridgeInterceptionFunction · 0.92
NewMethod · 0.65
AddMethod · 0.65
RunMethod · 0.65
EqualMethod · 0.45
LenMethod · 0.45

Tested by

no test coverage detected