From 22a88c579faf41407c8955fa959d7ba7f5a897ce Mon Sep 17 00:00:00 2001 From: Artur Mullakhmetov Date: Sun, 26 Jan 2020 12:51:23 +0300 Subject: [PATCH] Fix unstable test Make comment consistent with code Decrease timeout param to prevent unwanted 200 response --- backend/app/rest/api/migrator_test.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/backend/app/rest/api/migrator_test.go b/backend/app/rest/api/migrator_test.go index b298e295..196f764a 100644 --- a/backend/app/rest/api/migrator_test.go +++ b/backend/app/rest/api/migrator_test.go @@ -168,11 +168,12 @@ func TestMigrator_ImportWaitExpired(t *testing.T) { "picture":"/api/v1/avatar/remark.image","profile":"https://remark42.com","admin":true, "ip":"ae12fe3b5f129b5cc4cdd2b136b7b7947c4d2741"},"locator":{"site":"remark42","url":"https://radio-t.com/blah1"},"score":0, "votes":{},"time":"2018-04-30T01:37:00.849053725-05:00"}` - recs := []string{} - for i := 0; i < 50; i++ { + nRecs := 50 + recs := make([]string, 0, nRecs) + for i := 0; i < nRecs; i++ { recs = append(recs, fmt.Sprintf(tmpl, i)) } - r := strings.NewReader(`{"version":1}` + strings.Join(recs, "\n")) // reader with 10k records + r := strings.NewReader(`{"version":1}` + strings.Join(recs, "\n")) // reader with `nRecs` records client := &http.Client{Timeout: 5 * time.Second} req, err := http.NewRequest("POST", ts.URL+"/api/v1/admin/import?site=remark42&provider=native", r) require.NoError(t, err) @@ -183,7 +184,7 @@ func TestMigrator_ImportWaitExpired(t *testing.T) { assert.Equal(t, http.StatusAccepted, resp.StatusCode) client = &http.Client{Timeout: 5 * time.Second} - req, err = http.NewRequest("GET", ts.URL+"/api/v1/admin/wait?site=remark42&timeout=10ms", nil) + req, err = http.NewRequest("GET", ts.URL+"/api/v1/admin/wait?site=remark42&timeout=5ms", nil) require.NoError(t, err) req.SetBasicAuth("admin", "password") assert.NoError(t, err)