forked from PagerDuty/terraform-provider-pagerduty
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f55f9f9
commit e254342
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package util | ||
|
||
import ( | ||
"fmt" | ||
"reflect" | ||
"testing" | ||
|
||
"github.com/hashicorp/go-cty/cty" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" | ||
) | ||
|
||
func TestValidateTZValueDiagFunc(t *testing.T) { | ||
notValidTZ1 := "not a valid TZ" | ||
|
||
cases := []struct { | ||
given string | ||
want diag.Diagnostics | ||
path cty.Path | ||
}{ | ||
{ | ||
given: "America/Montevideo", | ||
want: nil, | ||
path: cty.Path{}, | ||
}, | ||
{ | ||
given: "America/Indiana/Indianapolis", | ||
want: nil, | ||
path: cty.Path{}, | ||
}, | ||
{ | ||
given: notValidTZ1, | ||
want: diag.Diagnostics{diag.Diagnostic{Severity: 0, Summary: fmt.Sprintf("\"%s\" is a not valid input. Please refer to the list of allowed Time Zone values at https://developer.pagerduty.com/docs/1afe25e9c94cb-types#time-zone", notValidTZ1), Detail: "", AttributePath: cty.Path{cty.GetAttrStep{Name: "time_zone"}}}}, | ||
path: cty.Path{cty.GetAttrStep{Name: "time_zone"}}, | ||
}, | ||
} | ||
|
||
for _, c := range cases { | ||
got := ValidateTZValueDiagFunc(c.given, c.path) | ||
if !reflect.DeepEqual(got, c.want) { | ||
t.Errorf("want %v; got %v", c.want, got) | ||
} | ||
} | ||
} |