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
|
From: Shengjing Zhu <i@zhsj.me>
Date: Sat, 22 Jul 2017 23:36:52 +0800
Subject: Fix time test
two time.Now() results may be equal when they are got very closely.
https://github.com/go-playground/validator/issues/294
Signed-off-by: Shengjing Zhu <i@zhsj.me>
---
validator_test.go | 2 ++
1 file changed, 2 insertions(+)
diff --git a/validator_test.go b/validator_test.go
index ee61527..62f5179 100644
--- a/validator_test.go
+++ b/validator_test.go
@@ -4876,6 +4876,7 @@ func TestIsGte(t *testing.T) {
Equal(t, errs, nil)
t2 := time.Now().UTC()
+ t2 = t2.Add(time.Hour * -1)
errs = validate.Field(t2, "gte")
NotEqual(t, errs, nil)
@@ -4921,6 +4922,7 @@ func TestIsLt(t *testing.T) {
PanicMatches(t, func() { validate.Field(i, "lt") }, "Bad field type bool")
t1 := time.Now().UTC()
+ t1 = t1.Add(time.Hour * -1)
errs = validate.Field(t1, "lt")
Equal(t, errs, nil)
|