terraform/builtin/providers/github/util_test.go

56 lines
1.0 KiB
Go
Raw Normal View History

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 := validateRoleValueFunc([]string{"valid_one", "valid_two"})
for _, tc := range cases {
_, errors := validationFunc(tc.Value, "github_membership")
if len(errors) != tc.ErrCount {
t.Fatalf("Expected github_membership to trigger a 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)
}
}