-
Notifications
You must be signed in to change notification settings - Fork 87
/
Copy pathdeadline_test.go
33 lines (28 loc) · 1.18 KB
/
deadline_test.go
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
32
33
package en_test
import (
"testing"
"time"
"github.com/olebedev/when"
"github.com/olebedev/when/rules"
"github.com/olebedev/when/rules/en"
)
func TestDeadline(t *testing.T) {
fixt := []Fixture{
{"within half an hour", 0, "within half an hour", time.Hour / 2},
{"within 1 hour", 0, "within 1 hour", time.Hour},
{"in 5 minutes", 0, "in 5 minutes", time.Minute * 5},
{"In 5 minutes I will go home", 0, "In 5 minutes", time.Minute * 5},
{"we have to do something within 10 days.", 24, "within 10 days", 10 * 24 * time.Hour},
{"we have to do something in five days.", 24, "in five days", 5 * 24 * time.Hour},
{"we have to do something in 5 days.", 24, "in 5 days", 5 * 24 * time.Hour},
{"In 5 seconds A car need to move", 0, "In 5 seconds", 5 * time.Second},
{"within two weeks", 0, "within two weeks", 14 * 24 * time.Hour},
{"within a month", 0, "within a month", 31 * 24 * time.Hour},
{"within a few months", 0, "within a few months", 91 * 24 * time.Hour},
{"within one year", 0, "within one year", 366 * 24 * time.Hour},
{"in a week", 0, "in a week", 7 * 24 * time.Hour},
}
w := when.New(nil)
w.Add(en.Deadline(rules.Skip))
ApplyFixtures(t, "en.Deadline", w, fixt)
}