package governance import ( "errors" "testing" ) // TestModelPolicyAllowsEveryAliasOnlyWhenUnset guards the model policy // boundary: no policy lets every alias through, while a policy that names no // alias allows none. func TestModelPolicyAllowsEveryAliasOnlyWhenUnset(t *testing.T) { cases := []struct { name string allowed []string alias string wantErr error }{ {"no policy allows the default", nil, "", nil}, {"no policy allows a named alias", nil, "fast", nil}, {"a policy naming nothing allows no alias", []string{}, "", ErrModelNotAllowed}, {"a policy allows what it names", []string{"default", "fast"}, "fast", nil}, {"a policy refuses the alias it leaves out", []string{"fast"}, "", ErrModelNotAllowed}, } for _, c := range cases { t.Run(c.name, func(t *testing.T) { if err := allowedAlias(c.allowed, c.alias); !errors.Is(err, c.wantErr) { t.Fatalf("allowedAlias(%v, %q) error = %v, want %v", c.allowed, c.alias, err, c.wantErr) } }) } }