From 5d8a3ea78b27f9fe2ae8fd6f63c9173a4136d29f Mon Sep 17 00:00:00 2001 From: Umputun Date: Sat, 12 May 2018 11:42:34 -0500 Subject: [PATCH] lint: test shadowing --- app/rest/api/admin_test.go | 12 ++++++------ app/rest/api/rest_test.go | 2 ++ app/rest/auth/provider_test.go | 1 + 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/rest/api/admin_test.go b/app/rest/api/admin_test.go index 3ee4fb18..e874a3a7 100644 --- a/app/rest/api/admin_test.go +++ b/app/rest/api/admin_test.go @@ -105,13 +105,13 @@ func TestAdmin_Block(t *testing.T) { block := func(val int) (code int, body []byte) { client := http.Client{} - req, err := http.NewRequest(http.MethodPut, + req, e := http.NewRequest(http.MethodPut, fmt.Sprintf("http://dev:password@127.0.0.1:%d/api/v1/admin/user/%s?site=radio-t&block=%d", port, "user1", val), nil) - assert.Nil(t, err) - resp, err := client.Do(req) - require.Nil(t, err) - body, err = ioutil.ReadAll(resp.Body) - assert.Nil(t, err) + assert.Nil(t, e) + resp, e := client.Do(req) + require.Nil(t, e) + body, e = ioutil.ReadAll(resp.Body) + assert.Nil(t, e) resp.Body.Close() return resp.StatusCode, body } diff --git a/app/rest/api/rest_test.go b/app/rest/api/rest_test.go index 493a3d73..78f4fdbd 100644 --- a/app/rest/api/rest_test.go +++ b/app/rest/api/rest_test.go @@ -84,6 +84,7 @@ func TestServer_Preview(t *testing.T) { 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/preview", port), "application/json", r) + assert.Nil(t, err) assert.Equal(t, http.StatusOK, resp.StatusCode) b, err := ioutil.ReadAll(resp.Body) assert.Nil(t, err) @@ -111,6 +112,7 @@ BKT t.Log(j) r := strings.NewReader(j) resp, err := http.Post(fmt.Sprintf("http://dev:password@127.0.0.1:%d/api/v1/preview", port), "application/json", r) + assert.Nil(t, err) assert.Equal(t, http.StatusOK, resp.StatusCode) b, err := ioutil.ReadAll(resp.Body) assert.Nil(t, err) diff --git a/app/rest/auth/provider_test.go b/app/rest/auth/provider_test.go index f7ac15d7..b5c522b7 100644 --- a/app/rest/auth/provider_test.go +++ b/app/rest/auth/provider_test.go @@ -30,6 +30,7 @@ func TestLogin(t *testing.T) { assert.Nil(t, err) assert.Equal(t, 200, resp.StatusCode) body, err := ioutil.ReadAll(resp.Body) + assert.Nil(t, err) t.Logf("resp %s", string(body)) u := store.User{} err = json.Unmarshal(body, &u)