github.com/minamijoyo/terraform@v0.7.8-0.20161029001309-18b3736ba44b/builtin/providers/github/util_test.go (about) 1 package github 2 3 import ( 4 "testing" 5 ) 6 7 func TestAccGithubUtilRole_validation(t *testing.T) { 8 cases := []struct { 9 Value string 10 ErrCount int 11 }{ 12 { 13 Value: "invalid", 14 ErrCount: 1, 15 }, 16 { 17 Value: "valid_one", 18 ErrCount: 0, 19 }, 20 { 21 Value: "valid_two", 22 ErrCount: 0, 23 }, 24 } 25 26 validationFunc := validateValueFunc([]string{"valid_one", "valid_two"}) 27 28 for _, tc := range cases { 29 _, errors := validationFunc(tc.Value, "test_arg") 30 31 if len(errors) != tc.ErrCount { 32 t.Fatalf("Expected 1 validation error") 33 } 34 } 35 } 36 37 func TestAccGithubUtilTwoPartID(t *testing.T) { 38 partOne, partTwo := "foo", "bar" 39 40 id := buildTwoPartID(&partOne, &partTwo) 41 42 if id != "foo:bar" { 43 t.Fatalf("Expected two part id to be foo:bar, actual: %s", id) 44 } 45 46 parsedPartOne, parsedPartTwo := parseTwoPartID(id) 47 48 if parsedPartOne != "foo" { 49 t.Fatalf("Expected parsed part one foo, actual: %s", parsedPartOne) 50 } 51 52 if parsedPartTwo != "bar" { 53 t.Fatalf("Expected parsed part two bar, actual: %s", parsedPartTwo) 54 } 55 }