MCPcopy Create free account
hub / github.com/compozy/agh / TestValidateScopeBinding

Function TestValidateScopeBinding

internal/task/validate_test.go:11–46  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestValidateScopeBinding(t *testing.T) {
12 t.Parallel()
13
14 tests := []struct {
15 name string
16 scope Scope
17 workspaceID string
18 wantErr error
19 }{
20 {name: "global without workspace", scope: ScopeGlobal},
21 {name: "workspace with workspace", scope: ScopeWorkspace, workspaceID: "ws-1"},
22 {name: "global with workspace", scope: ScopeGlobal, workspaceID: "ws-1", wantErr: ErrInvalidScopeBinding},
23 {name: "workspace without workspace", scope: ScopeWorkspace, wantErr: ErrInvalidScopeBinding},
24 {name: "unsupported scope", scope: Scope("tenant"), wantErr: ErrValidation},
25 }
26
27 for _, tt := range tests {
28 t.Run(tt.name, func(t *testing.T) {
29 t.Parallel()
30
31 err := ValidateScopeBinding(tt.scope, tt.workspaceID, "task", "workspace_id")
32 if tt.wantErr == nil {
33 if err != nil {
34 t.Fatalf("ValidateScopeBinding() error = %v", err)
35 }
36 return
37 }
38 if err == nil {
39 t.Fatal("ValidateScopeBinding() error = nil, want non-nil")
40 }
41 if !errors.Is(err, tt.wantErr) {
42 t.Fatalf("ValidateScopeBinding() error = %v, want %v", err, tt.wantErr)
43 }
44 })
45 }
46}
47
48func TestValidateImmutableTaskFields(t *testing.T) {
49 t.Parallel()

Callers

nothing calls this directly

Calls 4

ScopeTypeAlias · 0.70
ValidateScopeBindingFunction · 0.70
RunMethod · 0.65
IsMethod · 0.45

Tested by

no test coverage detected