Skip to content

Commit

Permalink
client creator moved from tests area to main code
Browse files Browse the repository at this point in the history
  • Loading branch information
Egor Plotkin authored and jbreitbart committed Jul 17, 2022
1 parent f818b5b commit ce625c4
Show file tree
Hide file tree
Showing 14 changed files with 95 additions and 55 deletions.
4 changes: 2 additions & 2 deletions album_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ func TestAlbumImgurSimulated(t *testing.T) {
httpC, server := testHTTPClientJSON("{\"data\":{\"id\":\"VZQXk\",\"title\":\"Gianluca Gimini's bikes\",\"description\":null,\"datetime\":1460715031,\"cover\":\"CJCA0gW\",\"cover_width\":1200,\"cover_height\":786,\"account_url\":\"mrcassette\",\"account_id\":157430,\"privacy\":\"public\",\"layout\":\"blog\",\"views\":667581,\"link\":\"https:\\/\\/imgur.com\\/a\\/VZQXk\",\"favorite\":false,\"nsfw\":false,\"section\":\"pics\",\"images_count\":1,\"in_gallery\":true,\"images\":[{\"id\":\"CJCA0gW\",\"title\":null,\"description\":\"by Designer Gianluca Gimini\\nhttps:\\/\\/www.behance.net\\/gallery\\/35437979\\/Velocipedia\",\"datetime\":1460715032,\"type\":\"image\\/jpeg\",\"animated\":false,\"width\":1200,\"height\":786,\"size\":362373,\"views\":4420880,\"bandwidth\":1602007548240,\"vote\":null,\"favorite\":false,\"nsfw\":null,\"section\":null,\"account_url\":null,\"account_id\":null,\"in_gallery\":false,\"link\":\"https:\\/\\/i.imgur.com\\/CJCA0gW.jpg\"}]},\"success\":true,\"status\":200}")
defer server.Close()

client := createClient(httpC, "testing", "")
client, _ := NewClient(httpC, "testing", "")
alb, status, err := client.GetAlbumInfo("VZQXk")

if err != nil {
Expand Down Expand Up @@ -58,7 +58,7 @@ func TestAlbumImgurReal(t *testing.T) {
}
RapidAPIKey := os.Getenv("RapidAPIKEY")

client := createClient(new(http.Client), key, RapidAPIKey)
client, _ := NewClient(new(http.Client), key, RapidAPIKey)

alb, status, err := client.GetAlbumInfo("VZQXk")

Expand Down
23 changes: 23 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package imgur

import (
"fmt"
"net/http"

"github.com/koffeinsource/go-klogger"
Expand All @@ -13,3 +14,25 @@ type Client struct {
ImgurClientID string
RapidAPIKEY string
}

// NewClient simply creates an imgur client. RapidAPIKEY is "" if you are using the free API.
func NewClient(httpClient *http.Client, clientID string, rapidAPIKEY string) (*Client, error) {
logger := new(klogger.CLILogger)

if len(clientID) == 0 {
msg := "imgur client ID is empty"
logger.Errorf(msg)
return nil, fmt.Errorf(msg)
}

if len(rapidAPIKEY) == 0 {
logger.Infof("rapid api key is empty")
}

return &Client{
HTTPClient: httpClient,
Log: logger,
ImgurClientID: clientID,
RapidAPIKEY: rapidAPIKEY,
}, nil
}
18 changes: 18 additions & 0 deletions client_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package imgur

import (
"net/http"
"testing"

"github.com/stretchr/testify/require"
)

func TestClientCreationWithoutClientID(t *testing.T) {
client, err := NewClient(new(http.Client), "", "")
require.Error(t, err)
require.Nil(t, client)

client, err = NewClient(new(http.Client), "some client id", "")
require.NoError(t, err)
require.NotNil(t, client)
}
18 changes: 0 additions & 18 deletions createClient_test.go

This file was deleted.

24 changes: 12 additions & 12 deletions fromURL_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func TestGetFromURLAlbumSimulated(t *testing.T) {
httpC, server := testHTTPClientJSON("{\"data\":{\"id\":\"VZQXk\",\"title\":\"Gianluca Gimini's bikes\",\"description\":null,\"datetime\":1460715031,\"cover\":\"CJCA0gW\",\"cover_width\":1200,\"cover_height\":786,\"account_url\":\"mrcassette\",\"account_id\":157430,\"privacy\":\"public\",\"layout\":\"blog\",\"views\":667581,\"link\":\"https:\\/\\/imgur.com\\/a\\/VZQXk\",\"favorite\":false,\"nsfw\":false,\"section\":\"pics\",\"images_count\":1,\"in_gallery\":true,\"images\":[{\"id\":\"CJCA0gW\",\"title\":null,\"description\":\"by Designer Gianluca Gimini\\nhttps:\\/\\/www.behance.net\\/gallery\\/35437979\\/Velocipedia\",\"datetime\":1460715032,\"type\":\"image\\/jpeg\",\"animated\":false,\"width\":1200,\"height\":786,\"size\":362373,\"views\":4420880,\"bandwidth\":1602007548240,\"vote\":null,\"favorite\":false,\"nsfw\":null,\"section\":null,\"account_url\":null,\"account_id\":null,\"in_gallery\":false,\"link\":\"https:\\/\\/i.imgur.com\\/CJCA0gW.jpg\"}]},\"success\":true,\"status\":200}")
defer server.Close()

client := createClient(httpC, "testing", "")
client, _ := NewClient(httpC, "testing", "")
ge, status, err := client.GetInfoFromURL("https://imgur.com/a/VZQXk")

if err != nil {
Expand Down Expand Up @@ -43,7 +43,7 @@ func TestGetFromURLAlbumReal(t *testing.T) {
}
RapidAPIKey := os.Getenv("RapidAPIKEY")

client := createClient(new(http.Client), key, RapidAPIKey)
client, _ := NewClient(new(http.Client), key, RapidAPIKey)

ge, status, err := client.GetInfoFromURL("https://imgur.com/a/VZQXk")

Expand Down Expand Up @@ -71,7 +71,7 @@ func TestGetFromURLAlbumReal(t *testing.T) {
func TestGetFromURLAlbumNoID(t *testing.T) {
httpC, server := testHTTPClient500()
defer server.Close()
client := createClient(httpC, "testing", "")
client, _ := NewClient(httpC, "testing", "")

_, _, err := client.GetInfoFromURL("https://imgur.com/a/")

Expand All @@ -84,7 +84,7 @@ func TestGetFromURLAlbumNoID(t *testing.T) {
func TestGetFromURLGalleryNoID(t *testing.T) {
httpC, server := testHTTPClient500()
defer server.Close()
client := createClient(httpC, "testing", "")
client, _ := NewClient(httpC, "testing", "")

_, _, err := client.GetInfoFromURL("https://imgur.com/gallery/")

Expand All @@ -98,7 +98,7 @@ func TestGetFromURLGAlbumSimulated(t *testing.T) {
httpC, server := testHTTPClientJSON("{\"data\":{\"id\":\"VZQXk\",\"title\":\"As it turns out, most people cannot draw a bike.\",\"description\":null,\"datetime\":1460715031,\"cover\":\"CJCA0gW\",\"cover_width\":1200,\"cover_height\":786,\"account_url\":\"mrcassette\",\"account_id\":157430,\"privacy\":\"public\",\"layout\":\"blog\",\"views\":667581,\"link\":\"https:\\/\\/imgur.com\\/a\\/VZQXk\",\"ups\":13704,\"downs\":113,\"favorite\":false,\"nsfw\":false,\"section\":\"pics\",\"images_count\":1,\"in_gallery\":true,\"images\":[{\"id\":\"CJCA0gW\",\"title\":null,\"description\":\"by Designer Gianluca Gimini\\nhttps:\\/\\/www.behance.net\\/gallery\\/35437979\\/Velocipedia\",\"datetime\":1460715032,\"type\":\"image\\/jpeg\",\"animated\":false,\"width\":1200,\"height\":786,\"size\":362373,\"views\":4420880,\"bandwidth\":1602007548240,\"vote\":null,\"favorite\":false,\"nsfw\":null,\"section\":null,\"account_url\":null,\"account_id\":null,\"in_gallery\":false,\"link\":\"https:\\/\\/i.imgur.com\\/CJCA0gW.jpg\"}]},\"success\":true,\"status\":200}")
defer server.Close()

client := createClient(httpC, "testing", "")
client, _ := NewClient(httpC, "testing", "")
ge, status, err := client.GetInfoFromURL("https://imgur.com/gallery/VZQXk")

if err != nil {
Expand Down Expand Up @@ -129,7 +129,7 @@ func TestGetFromURLGAlbumReal(t *testing.T) {
}
RapidAPIKey := os.Getenv("RapidAPIKEY")

client := createClient(new(http.Client), key, RapidAPIKey)
client, _ := NewClient(new(http.Client), key, RapidAPIKey)

tests := []struct {
galleryURL string
Expand Down Expand Up @@ -212,7 +212,7 @@ func TestGetURLGalleryImageReal(t *testing.T) {
}
RapidAPIKey := os.Getenv("RapidAPIKEY")

client := createClient(new(http.Client), key, RapidAPIKey)
client, _ := NewClient(new(http.Client), key, RapidAPIKey)

ge, status, err := client.GetInfoFromURL("https://imgur.com/gallery/uPI76jY")

Expand Down Expand Up @@ -290,7 +290,7 @@ func TestGetURLImageReal(t *testing.T) {
}
RapidAPIKey := os.Getenv("RapidAPIKEY")

client := createClient(new(http.Client), key, RapidAPIKey)
client, _ := NewClient(new(http.Client), key, RapidAPIKey)

ge, status, err := client.GetInfoFromURL("https://imgur.com/ClF8rLe")

Expand Down Expand Up @@ -333,7 +333,7 @@ func TestGetFromURLImageNoID(t *testing.T) {
httpC, server := testHTTPClient500()
defer server.Close()

client := createClient(httpC, "testing", "")
client, _ := NewClient(httpC, "testing", "")
_, _, err := client.GetInfoFromURL("https://imgur.com/")

if err == nil {
Expand All @@ -346,7 +346,7 @@ func TestGetURLDirectImageSimulated(t *testing.T) {
httpC, server := testHTTPClientJSON("{\"data\":{\"id\":\"ClF8rLe\",\"title\":null,\"description\":null,\"datetime\":1451248840,\"type\":\"image\\/jpeg\",\"animated\":false,\"width\":2448,\"height\":3264,\"size\":1071339,\"views\":176,\"bandwidth\":188555664,\"vote\":null,\"favorite\":false,\"nsfw\":null,\"section\":null,\"account_url\":null,\"account_id\":null,\"in_gallery\":false,\"link\":\"https:\\/\\/i.imgur.com\\/ClF8rLe.jpg\"},\"success\":true,\"status\":200}")
defer server.Close()

client := createClient(httpC, "testing", "")
client, _ := NewClient(httpC, "testing", "")
ge, status, err := client.GetInfoFromURL("https://i.imgur.com/ClF8rLe.jpg")

if err != nil {
Expand Down Expand Up @@ -391,7 +391,7 @@ func TestGetURLDirectImageReal(t *testing.T) {
}
RapidAPIKey := os.Getenv("RapidAPIKEY")

client := createClient(new(http.Client), key, RapidAPIKey)
client, _ := NewClient(new(http.Client), key, RapidAPIKey)

ge, status, err := client.GetInfoFromURL("https://i.imgur.com/ClF8rLe.jpg")

Expand Down Expand Up @@ -434,7 +434,7 @@ func TestGetFromURLDirectImageNoID(t *testing.T) {
httpC, server := testHTTPClient500()
defer server.Close()

client := createClient(httpC, "testing", "")
client, _ := NewClient(httpC, "testing", "")
_, _, err := client.GetInfoFromURL("https://i.imgur.com/")

if err == nil {
Expand Down
4 changes: 2 additions & 2 deletions galleryAlbum_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ func TestGalleryAlbumImgurSimulated(t *testing.T) {
httpC, server := testHTTPClientJSON("{\"data\":{\"id\":\"VZQXk\",\"title\":\"As it turns out, most people cannot draw a bike.\",\"description\":null,\"datetime\":1460715031,\"cover\":\"CJCA0gW\",\"cover_width\":1200,\"cover_height\":786,\"account_url\":\"mrcassette\",\"account_id\":157430,\"privacy\":\"public\",\"layout\":\"blog\",\"views\":667581,\"link\":\"https:\\/\\/imgur.com\\/a\\/VZQXk\",\"ups\":13704,\"downs\":113,\"favorite\":false,\"nsfw\":false,\"section\":\"pics\",\"images_count\":1,\"in_gallery\":true,\"images\":[{\"id\":\"CJCA0gW\",\"title\":null,\"description\":\"by Designer Gianluca Gimini\\nhttps:\\/\\/www.behance.net\\/gallery\\/35437979\\/Velocipedia\",\"datetime\":1460715032,\"type\":\"image\\/jpeg\",\"animated\":false,\"width\":1200,\"height\":786,\"size\":362373,\"views\":4420880,\"bandwidth\":1602007548240,\"vote\":null,\"favorite\":false,\"nsfw\":null,\"section\":null,\"account_url\":null,\"account_id\":null,\"in_gallery\":false,\"link\":\"https:\\/\\/i.imgur.com\\/CJCA0gW.jpg\"}]},\"success\":true,\"status\":200}")
defer server.Close()

client := createClient(httpC, "testing", "")
client, _ := NewClient(httpC, "testing", "")
alb, status, err := client.GetGalleryAlbumInfo("VZQXk")

if err != nil {
Expand All @@ -34,7 +34,7 @@ func TestGalleryAlbumImgurReal(t *testing.T) {
}
RapidAPIKey := os.Getenv("RapidAPIKEY")

client := createClient(new(http.Client), key, RapidAPIKey)
client, _ := NewClient(new(http.Client), key, RapidAPIKey)

alb, status, err := client.GetGalleryAlbumInfo("VZQXk")

Expand Down
4 changes: 2 additions & 2 deletions galleryImage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ func TestGalleryImageImgurSimulated(t *testing.T) {
httpC, server := testHTTPClientJSON("{\"data\":{\"id\":\"Hf6cs\",\"title\":\"The Tridge. (three way bridge)\",\"description\":null,\"datetime\":1316367003,\"type\":\"image\\/jpeg\",\"animated\":false,\"width\":1700,\"height\":1133,\"size\":268126,\"views\":1342557,\"bandwidth\":359974438182,\"vote\":null,\"favorite\":false,\"nsfw\":false,\"section\":\"pics\",\"account_url\":null,\"account_id\":null,\"in_gallery\":true,\"topic\":null,\"topic_id\":0,\"link\":\"https:\\/\\/i.imgur.com\\/Hf6cs.jpg\",\"comment_count\":90,\"ups\":585,\"downs\":3,\"points\":582,\"score\":1136,\"is_album\":false},\"success\":true,\"status\":200}")
defer server.Close()

client := createClient(httpC, "testing", "")
client, _ := NewClient(httpC, "testing", "")
img, status, err := client.GetGalleryImageInfo("Hf6cs")

if err != nil {
Expand All @@ -34,7 +34,7 @@ func TestGalleryImageImgurReal(t *testing.T) {
}
RapidAPIKey := os.Getenv("RapidAPIKEY")

client := createClient(new(http.Client), key, RapidAPIKey)
client, _ := NewClient(new(http.Client), key, RapidAPIKey)

img, status, err := client.GetGalleryImageInfo("Hf6cs")

Expand Down
5 changes: 4 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ module github.com/koffeinsource/go-imgur

go 1.14

require github.com/koffeinsource/go-klogger v0.1.1
require (
github.com/koffeinsource/go-klogger v0.1.1
github.com/stretchr/testify v1.8.0 // indirect
)
14 changes: 14 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.5 h1:F768QJ1E9tib+q5Sc8MkdJi1RxLTbRcTf8LJV56aRls=
github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk=
github.com/koffeinsource/go-klogger v0.1.1 h1:FImHHVcDwEV4Ze3uOtRmBTQdJdzuBHtrvR4B8ssKkbw=
github.com/koffeinsource/go-klogger v0.1.1/go.mod h1:oqHKXZOZt4uktar7WIYuEyWJRRlrkRSX+Uj1DWGZ79I=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e h1:3G+cUijn7XD+S4eJFddp53Pv7+slrESplyjG25HgL+k=
Expand All @@ -14,3 +24,7 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
google.golang.org/appengine v1.6.5 h1:tycE03LOZYQNhDpS27tcQdAzLCVMaj7QT2SXxebnpCM=
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
4 changes: 2 additions & 2 deletions image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ func TestImageImgurSimulated(t *testing.T) {
httpC, server := testHTTPClientJSON("{\"data\":{\"id\":\"ClF8rLe\",\"title\":null,\"description\":null,\"datetime\":1451248840,\"type\":\"image\\/jpeg\",\"animated\":false,\"width\":2448,\"height\":3264,\"size\":1071339,\"views\":176,\"bandwidth\":188555664,\"vote\":null,\"favorite\":false,\"nsfw\":null,\"section\":null,\"account_url\":null,\"account_id\":null,\"in_gallery\":false,\"link\":\"https:\\/\\/i.imgur.com\\/ClF8rLe.jpg\"},\"success\":true,\"status\":200}")
defer server.Close()

client := createClient(httpC, "testing", "")
client, _ := NewClient(httpC, "testing", "")
img, status, err := client.GetImageInfo("ClF8rLe")

if err != nil {
Expand All @@ -34,7 +34,7 @@ func TestImageImgurReal(t *testing.T) {
}
RapidAPIKey := os.Getenv("RapidAPIKEY")

client := createClient(new(http.Client), key, RapidAPIKey)
client, _ := NewClient(new(http.Client), key, RapidAPIKey)

img, status, err := client.GetImageInfo("ClF8rLe")

Expand Down
10 changes: 5 additions & 5 deletions imgurcmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"net/http"

"github.com/koffeinsource/go-imgur"
"github.com/koffeinsource/go-klogger"
)

func printRate(client *imgur.Client) {
Expand Down Expand Up @@ -89,10 +88,11 @@ func main() {
return
}

client := new(imgur.Client)
client.HTTPClient = new(http.Client)
client.Log = new(klogger.CLILogger)
client.ImgurClientID = *imgurClientID
client, err := imgur.NewClient(new(http.Client), *imgurClientID, "")
if err != nil {
fmt.Printf("failed during imgur client creation. %+v\n", err)
return
}

if *upload != "" {
_, st, err := client.UploadImageFromFile(*upload, "", "test title", "test desc")
Expand Down
6 changes: 3 additions & 3 deletions rateLimit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ func TestRateLimitImgurSimulated(t *testing.T) {

defer server.Close()

client := createClient(httpC, "testing", "")
client, _ := NewClient(httpC, "testing", "")
rl, err := client.GetRateLimit()

if err != nil {
Expand All @@ -35,7 +35,7 @@ func TestRateLimitRealRapidAPI(t *testing.T) {
t.Skip("RapidAPIKEY environment variable not set.")
}

client := createClient(new(http.Client), key, RapidAPIKey)
client, _ := NewClient(new(http.Client), key, RapidAPIKey)

rl, err := client.GetRateLimit()

Expand All @@ -57,7 +57,7 @@ func TestRateLimitRealImgur(t *testing.T) {
t.Skip("IMGURCLIENTID environment variable not set.")
}

client := createClient(new(http.Client), key, "")
client, _ := NewClient(new(http.Client), key, "")

rl, err := client.GetRateLimit()

Expand Down
10 changes: 5 additions & 5 deletions serverError_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ func TestImgurNotSuccess(t *testing.T) {
httpC, server := testHTTPClientJSON("{\"data\": {}, \"success\": false, \"status\": 200 }")
defer server.Close()

client := createClient(httpC, "testing", "")
client, _ := NewClient(httpC, "testing", "")

_, err := client.GetRateLimit()

Expand Down Expand Up @@ -56,7 +56,7 @@ func TestJsonError(t *testing.T) {
httpC, server := testHTTPClientInvalidJSON()
defer server.Close()

client := createClient(httpC, "testing", "")
client, _ := NewClient(httpC, "testing", "")

img, _, err := client.GetImageInfo("asd")

Expand Down Expand Up @@ -101,7 +101,7 @@ func TestServerError(t *testing.T) {
httpC, server := testHTTPClient500()
defer server.Close()

client := createClient(httpC, "testing", "")
client, _ := NewClient(httpC, "testing", "")

_, err := client.GetRateLimit()

Expand Down Expand Up @@ -151,7 +151,7 @@ func TestImgurError(t *testing.T) {
httpC, server := testHTTPClientJSON("{'data' : {}, 'success' : false, 'status' : 500}")
defer server.Close()

client := createClient(httpC, "testing", "")
client, _ := NewClient(httpC, "testing", "")
_, err := client.GetRateLimit()

if err == nil {
Expand Down Expand Up @@ -200,7 +200,7 @@ func TestServerDown(t *testing.T) {
httpC, server := testHTTPClient500()
server.Close()

client := createClient(httpC, "testing", "")
client, _ := NewClient(httpC, "testing", "")
_, err := client.GetRateLimit()

if err == nil {
Expand Down
Loading

0 comments on commit ce625c4

Please sign in to comment.