MCPcopy Create free account
hub / github.com/coder/coder / TestChatGPTFetch_ObjectIDParsing

Function TestChatGPTFetch_ObjectIDParsing

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

Source from the content-addressed store, hash-verified

492}
493
494func TestChatGPTFetch_ObjectIDParsing(t *testing.T) {
495 t.Parallel()
496
497 tests := []struct {
498 name string
499 objectID string
500 expectError bool
501 errorMsg string
502 }{
503 {
504 name: "ValidTemplateID",
505 objectID: "template:" + uuid.NewString(),
506 expectError: false,
507 },
508 {
509 name: "ValidWorkspaceID",
510 objectID: "workspace:" + uuid.NewString(),
511 expectError: false,
512 },
513 {
514 name: "MissingColon",
515 objectID: "template" + uuid.NewString(),
516 expectError: true,
517 errorMsg: "invalid ID",
518 },
519 {
520 name: "InvalidUUID",
521 objectID: "template:invalid-uuid",
522 expectError: true,
523 errorMsg: "invalid template ID, must be a valid UUID",
524 },
525 {
526 name: "UnsupportedType",
527 objectID: "user:" + uuid.NewString(),
528 expectError: true,
529 errorMsg: "invalid ID",
530 },
531 {
532 name: "EmptyID",
533 objectID: "",
534 expectError: true,
535 errorMsg: "invalid ID",
536 },
537 }
538
539 for _, tt := range tests {
540 t.Run(tt.name, func(t *testing.T) {
541 t.Parallel()
542
543 // Setup minimal environment
544 client, _ := coderdtest.NewWithDatabase(t, nil)
545 coderdtest.CreateFirstUser(t, client)
546
547 deps, err := toolsdk.NewDeps(client)
548 require.NoError(t, err)
549
550 // Execute tool
551 args := toolsdk.FetchArgs{ID: tt.objectID}

Callers

nothing calls this directly

Calls 7

NewWithDatabaseFunction · 0.92
CreateFirstUserFunction · 0.92
NewDepsFunction · 0.92
testToolFunction · 0.85
RunMethod · 0.65
ErrorMethod · 0.45
ContainsMethod · 0.45

Tested by

no test coverage detected