File size: 559 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
package schedule
import (
"testing"
"time"
)
func TestSchedule_Normalize(t *testing.T) {
test := func(valid bool, name string, s Schedule) {
t.Run(name, func(t *testing.T) {
_, err := s.Normalize()
if valid && err != nil {
t.Errorf("err = %v; want nil", err)
} else if !valid && err == nil {
t.Errorf("err = nil; want != nil")
}
})
}
data := []struct {
v bool
n string
s Schedule
}{
{false, "missing name", Schedule{Description: "hello", TimeZone: time.Local}},
}
for _, d := range data {
test(d.v, d.n, d.s)
}
}
|