(t *testing.T)
| 9 | ) |
| 10 | |
| 11 | func 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 | |
| 48 | func TestValidateImmutableTaskFields(t *testing.T) { |
| 49 | t.Parallel() |
nothing calls this directly
no test coverage detected