(t *testing.T)
| 12 | ) |
| 13 | |
| 14 | func TestFindChatAgent(t *testing.T) { |
| 15 | t.Parallel() |
| 16 | |
| 17 | newRootAgentWithID := func(id, name string, displayOrder int32) database.WorkspaceAgent { |
| 18 | return database.WorkspaceAgent{ |
| 19 | ID: uuid.MustParse(id), |
| 20 | Name: name, |
| 21 | DisplayOrder: displayOrder, |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | newRootAgent := func(name string, displayOrder int32) database.WorkspaceAgent { |
| 26 | return newRootAgentWithID(uuid.NewString(), name, displayOrder) |
| 27 | } |
| 28 | |
| 29 | newChildAgent := func(name string, displayOrder int32) database.WorkspaceAgent { |
| 30 | agent := newRootAgent(name, displayOrder) |
| 31 | agent.ParentID = uuid.NullUUID{UUID: uuid.New(), Valid: true} |
| 32 | return agent |
| 33 | } |
| 34 | |
| 35 | tests := []struct { |
| 36 | name string |
| 37 | agents []database.WorkspaceAgent |
| 38 | wantIndex int |
| 39 | wantErrContains []string |
| 40 | }{ |
| 41 | { |
| 42 | name: "SingleSuffixMatch", |
| 43 | agents: []database.WorkspaceAgent{ |
| 44 | newRootAgent("alpha", 0), |
| 45 | newRootAgent("dev-coderd-chat", 2), |
| 46 | newRootAgent("zeta", 1), |
| 47 | }, |
| 48 | wantIndex: 1, |
| 49 | }, |
| 50 | { |
| 51 | name: "SuffixMatchCaseInsensitive", |
| 52 | agents: []database.WorkspaceAgent{ |
| 53 | newRootAgent("alpha", 0), |
| 54 | newRootAgent("Dev-Coderd-Chat", 2), |
| 55 | newRootAgent("zeta", 1), |
| 56 | }, |
| 57 | wantIndex: 1, |
| 58 | }, |
| 59 | { |
| 60 | name: "NoSuffixMatchFallbackDeterministic", |
| 61 | agents: []database.WorkspaceAgent{ |
| 62 | newRootAgent("zeta", 2), |
| 63 | newRootAgent("bravo", 1), |
| 64 | newRootAgent("alpha", 1), |
| 65 | }, |
| 66 | wantIndex: 2, |
| 67 | }, |
| 68 | { |
| 69 | name: "NoSuffixMatchFallbackByName", |
| 70 | agents: []database.WorkspaceAgent{ |
| 71 | newRootAgent("Bravo", 3), |
nothing calls this directly
no test coverage detected