mirror of
https://github.com/opentofu/opentofu.git
synced 2025-01-08 15:13:56 -06:00
7721348b0b
Added the ability to set the "privacy" of a github_team resource so all teams won't automatically set to private. * Added the privacy argument to github_team * Refactored parameter validation to be general for any argument * Updated testing
56 lines
1.0 KiB
Go
56 lines
1.0 KiB
Go
package github
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestAccGithubUtilRole_validation(t *testing.T) {
|
|
cases := []struct {
|
|
Value string
|
|
ErrCount int
|
|
}{
|
|
{
|
|
Value: "invalid",
|
|
ErrCount: 1,
|
|
},
|
|
{
|
|
Value: "valid_one",
|
|
ErrCount: 0,
|
|
},
|
|
{
|
|
Value: "valid_two",
|
|
ErrCount: 0,
|
|
},
|
|
}
|
|
|
|
validationFunc := validateValueFunc([]string{"valid_one", "valid_two"})
|
|
|
|
for _, tc := range cases {
|
|
_, errors := validationFunc(tc.Value, "test_arg")
|
|
|
|
if len(errors) != tc.ErrCount {
|
|
t.Fatalf("Expected 1 validation error")
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestAccGithubUtilTwoPartID(t *testing.T) {
|
|
partOne, partTwo := "foo", "bar"
|
|
|
|
id := buildTwoPartID(&partOne, &partTwo)
|
|
|
|
if id != "foo:bar" {
|
|
t.Fatalf("Expected two part id to be foo:bar, actual: %s", id)
|
|
}
|
|
|
|
parsedPartOne, parsedPartTwo := parseTwoPartID(id)
|
|
|
|
if parsedPartOne != "foo" {
|
|
t.Fatalf("Expected parsed part one foo, actual: %s", parsedPartOne)
|
|
}
|
|
|
|
if parsedPartTwo != "bar" {
|
|
t.Fatalf("Expected parsed part two bar, actual: %s", parsedPartTwo)
|
|
}
|
|
}
|