Allow managing members in the project resource (#480)

* Extend resource and datasource

* Adapt acc test to work without members

* Extend acc test and adjust resource

* Generate docs

* Fix lint

* Fix unit test

* Uniformize description with datasource and extend unit test

* Improve role field description

* Update TF state before adding/removing members

* Remove unused function

* Move intermediate map top state to mapProjectFields

* Improve code
This commit is contained in:
João Palet 2024-07-29 09:57:06 +01:00 committed by GitHub
parent af7d789945
commit 31ce9ab36d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 1195 additions and 169 deletions

View file

@ -299,6 +299,60 @@ func TestNoSeparator(t *testing.T) {
}
}
func TestNonLegacyProjectRole(t *testing.T) {
tests := []struct {
description string
input string
isValid bool
}{
{
"ok",
"owner",
true,
},
{
"ok-2",
"reader",
true,
},
{
"leagcy-role",
"project.owner",
false,
},
{
"leagcy-role-2",
"project.admin",
false,
},
{
"leagcy-role-3",
"project.member",
false,
},
{
"leagcy-role-4",
"project.auditor",
false,
},
}
for _, tt := range tests {
t.Run(tt.description, func(t *testing.T) {
r := validator.StringResponse{}
NonLegacyProjectRole().ValidateString(context.Background(), validator.StringRequest{
ConfigValue: types.StringValue(tt.input),
}, &r)
if !tt.isValid && !r.Diagnostics.HasError() {
t.Fatalf("Should have failed")
}
if tt.isValid && r.Diagnostics.HasError() {
t.Fatalf("Should not have failed: %v", r.Diagnostics.Errors())
}
})
}
}
func TestMinorVersionNumber(t *testing.T) {
tests := []struct {
description string