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

Function TestChatGPTSearch_WorkspaceSearch

codersdk/toolsdk/chatgpt_test.go:154–261  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

152}
153
154func TestChatGPTSearch_WorkspaceSearch(t *testing.T) {
155 t.Parallel()
156
157 tests := []struct {
158 name string
159 query string
160 setupOwner string // "self" or "other"
161 setupWorkspace bool
162 expectError bool
163 errorContains string
164 }{
165 {
166 name: "ValidWorkspacesQuery_CurrentUser",
167 query: "workspaces",
168 setupOwner: "self",
169 setupWorkspace: true,
170 expectError: false,
171 },
172 {
173 name: "ValidWorkspacesQuery_CurrentUserMe",
174 query: "workspaces/owner:me",
175 setupOwner: "self",
176 setupWorkspace: true,
177 expectError: false,
178 },
179 {
180 name: "ValidWorkspacesQuery_NoWorkspaces",
181 query: "workspaces",
182 setupOwner: "self",
183 setupWorkspace: false,
184 expectError: false,
185 },
186 {
187 name: "ValidWorkspacesQuery_SpecificUser",
188 query: "workspaces/owner:otheruser",
189 setupOwner: "other",
190 setupWorkspace: true,
191 expectError: false,
192 },
193 }
194
195 for _, tt := range tests {
196 t.Run(tt.name, func(t *testing.T) {
197 t.Parallel()
198
199 // Setup
200 client, store := coderdtest.NewWithDatabase(t, nil)
201 owner := coderdtest.CreateFirstUser(t, client)
202
203 var workspaceOwnerID uuid.UUID
204 var workspaceClient *codersdk.Client
205 if tt.setupOwner == "self" {
206 workspaceOwnerID = owner.UserID
207 workspaceClient = client
208 } else {
209 var workspaceOwner codersdk.User
210 workspaceClient, workspaceOwner = coderdtest.CreateAnotherUserMutators(t, client, owner.OrganizationID, nil, func(r *codersdk.CreateUserRequestWithOrgs) {
211 r.Username = "otheruser"

Callers

nothing calls this directly

Calls 13

NewWithDatabaseFunction · 0.92
CreateFirstUserFunction · 0.92
WorkspaceBuildFunction · 0.92
NewDepsFunction · 0.92
testToolFunction · 0.85
NotEmptyMethod · 0.80
RunMethod · 0.65
DoMethod · 0.65
ErrorMethod · 0.45
ContainsMethod · 0.45
LenMethod · 0.45

Tested by

no test coverage detected