Commit f62e3e7c authored by Nick Thomas's avatar Nick Thomas

Fix logic errors in gitlabnet client tests

parent 996b2e1d
...@@ -117,11 +117,11 @@ func TestClients(t *testing.T) { ...@@ -117,11 +117,11 @@ func TestClients(t *testing.T) {
func testSuccessfulGet(t *testing.T, client *GitlabClient) { func testSuccessfulGet(t *testing.T, client *GitlabClient) {
t.Run("Successful get", func(t *testing.T) { t.Run("Successful get", func(t *testing.T) {
response, err := client.Get("/hello") response, err := client.Get("/hello")
defer response.Body.Close()
require.NoError(t, err) require.NoError(t, err)
require.NotNil(t, response) require.NotNil(t, response)
defer response.Body.Close()
responseBody, err := ioutil.ReadAll(response.Body) responseBody, err := ioutil.ReadAll(response.Body)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, string(responseBody), "Hello") assert.Equal(t, string(responseBody), "Hello")
...@@ -133,11 +133,11 @@ func testSuccessfulPost(t *testing.T, client *GitlabClient) { ...@@ -133,11 +133,11 @@ func testSuccessfulPost(t *testing.T, client *GitlabClient) {
data := map[string]string{"key": "value"} data := map[string]string{"key": "value"}
response, err := client.Post("/post_endpoint", data) response, err := client.Post("/post_endpoint", data)
defer response.Body.Close()
require.NoError(t, err) require.NoError(t, err)
require.NotNil(t, response) require.NotNil(t, response)
defer response.Body.Close()
responseBody, err := ioutil.ReadAll(response.Body) responseBody, err := ioutil.ReadAll(response.Body)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "Echo: {\"key\":\"value\"}", string(responseBody)) assert.Equal(t, "Echo: {\"key\":\"value\"}", string(responseBody))
...@@ -189,11 +189,11 @@ func testBrokenRequest(t *testing.T, client *GitlabClient) { ...@@ -189,11 +189,11 @@ func testBrokenRequest(t *testing.T, client *GitlabClient) {
func testAuthenticationHeader(t *testing.T, client *GitlabClient) { func testAuthenticationHeader(t *testing.T, client *GitlabClient) {
t.Run("Authentication headers for GET", func(t *testing.T) { t.Run("Authentication headers for GET", func(t *testing.T) {
response, err := client.Get("/auth") response, err := client.Get("/auth")
defer response.Body.Close()
require.NoError(t, err) require.NoError(t, err)
require.NotNil(t, response) require.NotNil(t, response)
defer response.Body.Close()
responseBody, err := ioutil.ReadAll(response.Body) responseBody, err := ioutil.ReadAll(response.Body)
require.NoError(t, err) require.NoError(t, err)
...@@ -204,11 +204,11 @@ func testAuthenticationHeader(t *testing.T, client *GitlabClient) { ...@@ -204,11 +204,11 @@ func testAuthenticationHeader(t *testing.T, client *GitlabClient) {
t.Run("Authentication headers for POST", func(t *testing.T) { t.Run("Authentication headers for POST", func(t *testing.T) {
response, err := client.Post("/auth", map[string]string{}) response, err := client.Post("/auth", map[string]string{})
defer response.Body.Close()
require.NoError(t, err) require.NoError(t, err)
require.NotNil(t, response) require.NotNil(t, response)
defer response.Body.Close()
responseBody, err := ioutil.ReadAll(response.Body) responseBody, err := ioutil.ReadAll(response.Body)
require.NoError(t, err) require.NoError(t, err)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment