From e64101226aa82a1f624d0633ddfcf534403fd887 Mon Sep 17 00:00:00 2001 From: Umputun Date: Thu, 17 May 2018 15:43:19 -0500 Subject: [PATCH] dirty hack: avoid minute change in rss test --- app/rest/api/rss_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/rest/api/rss_test.go b/app/rest/api/rss_test.go index e5e3d50a..704d6107 100644 --- a/app/rest/api/rss_test.go +++ b/app/rest/api/rss_test.go @@ -16,6 +16,8 @@ func TestServer_RssPost(t *testing.T) { assert.NotNil(t, srv) defer cleanup(srv) + waitOnMinChange() + // add one more comment r := strings.NewReader(`{"text": "test 123", "locator":{"url": "https://radio-t.com/blah1", "site": "radio-t"}}`) resp, err := http.Post(fmt.Sprintf("http://dev:password@127.0.0.1:%d/api/v1/comment", port), "application/json", r) @@ -55,6 +57,8 @@ func TestServer_RssSite(t *testing.T) { assert.NotNil(t, srv) defer cleanup(srv) + waitOnMinChange() + pubDate := time.Now().Format(time.RFC1123Z) r := strings.NewReader(`{"text": "test 123", "locator":{"url": "https://radio-t.com/blah10", "site": "radio-t"}}`) @@ -100,6 +104,12 @@ func TestServer_RssSite(t *testing.T) { assert.Equal(t, expected, res) } +func waitOnMinChange() { + if time.Now().Second() == 59 { + time.Sleep(1001 * time.Millisecond) + } +} + // clean formatting, i.e. multiple spaces, \t, \n func cleanRssFormatting(expected, actual string) (string, string) { reSpaces := regexp.MustCompile(`[\s\p{Zs}]{2,}`)