Files
terraform-provider-threshold/internal/provider/resource_alias_target_validation_test.go
T
Amit Kotagi f059618167 feat(proj-alias): support project scoped alias via suffixes (#824)
* feat(proj-alias): support project scoped alias via suffixes

* fix: generate resouce docs using make gen

* fix: address review comments

* chore: make gen changes

* fix(proja-alias): validate scope id before calling remove alias suffix

* fix: filter unknown scopes in validation
2026-07-17 18:33:02 +05:30

53 lines
967 B
Go

// Copyright IBM Corp. 2020, 2026
// SPDX-License-Identifier: MPL-2.0
package provider
import "testing"
func TestValidateTargetAliasScope(t *testing.T) {
t.Parallel()
tests := []struct {
name string
scopeId string
wantError bool
}{
{
name: "org scope rejected",
scopeId: "o_1234567890",
wantError: true,
},
{
name: "global scope allowed",
scopeId: globalScopeId,
wantError: false,
},
{
name: "project scope allowed",
scopeId: "p_1234567890",
wantError: false,
},
{
name: "unknown scope type rejected",
scopeId: "s_1234567890",
wantError: true,
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
err := validateTargetAliasScope(tt.scopeId)
if tt.wantError && err == nil {
t.Fatal("expected error but got nil")
}
if !tt.wantError && err != nil {
t.Fatalf("unexpected error: %v", err)
}
})
}
}