Skip to content

Commit

Permalink
add test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
imjaroiswebdev committed Feb 29, 2024
1 parent f55f9f9 commit e254342
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions util/util_test.go
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)
}
}
}

0 comments on commit e254342

Please sign in to comment.