From b04846f6da0cfdb341a38e76ca8069a6cd792ef7 Mon Sep 17 00:00:00 2001 From: Nathaniel Caza Date: Mon, 25 Jun 2018 08:33:13 -0500 Subject: [PATCH] fix time race in scalar test --- example/scalars/scalar_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/example/scalars/scalar_test.go b/example/scalars/scalar_test.go index 34416ad92cf..65cf589a3f1 100644 --- a/example/scalars/scalar_test.go +++ b/example/scalars/scalar_test.go @@ -41,7 +41,9 @@ func TestScalars(t *testing.T) { fragment UserData on User { id name created tier address { location } }`, &resp) require.Equal(t, "1,2", resp.User.Address.Location) - require.Equal(t, time.Now().Unix(), resp.User.Created) + // There can be a delay between creation and test assertion, so we + // give some leeway to eliminate false positives.S + require.WithinDuration(t, time.Now(), time.Unix(resp.User.Created, 0), 5*time.Second) require.Equal(t, "6,66", resp.Search[0].Address.Location) require.Equal(t, int64(666), resp.Search[0].Created) require.Equal(t, "A", resp.Search[0].Tier)