Test on a site not protected by cloudflare, always test your code BEFORE CI
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Tyler 2019-10-03 21:32:00 -04:00
parent a1530dc7fa
commit 27e7dab209
2 changed files with 10 additions and 5 deletions

View File

@ -6,7 +6,7 @@ import (
)
func Test_LinkInfoApi_detectContentType(t *testing.T) {
api := &LinkInfoApi{}
api := New()
contentType := api.detectContentType("http://example.com", "")
@ -31,11 +31,11 @@ func Test_LinkInfoApi_defaultLinkHandler(t *testing.T) {
}
testLinks := []expectedData{
{"https://paste.ee", "Paste.ee", "text/html"},
{"http://example.com", "Example Domain", "text/html"},
{"http://techslides.com/demos/sample-videos/small.mp4", "", "video/mp4"},
}
api := &LinkInfoApi{}
api := New()
for _, link := range testLinks {
l, err := api.DefaultLinkHandler(link.Link)
@ -57,7 +57,7 @@ func Test_LinkInfoApi_defaultLinkHandler(t *testing.T) {
func Test_LinkInfoApi_retrieveHtmlLinkTitle(t *testing.T) {
ret := &LinkInfo{}
api := &LinkInfoApi{}
api := New()
if err := api.retrieveHtmlLinkTitle(ret, "http://example.com"); err != nil {
t.Fatal("Unable to retrieve html link title:", err)

View File

@ -3,6 +3,7 @@ package linkinfo
import (
"net/http"
"net/url"
"time"
)
type LinkHandler struct {
@ -25,7 +26,11 @@ type LinkInfo struct {
}
func New() *LinkInfoApi {
api := &LinkInfoApi{}
api := &LinkInfoApi{
Client: &http.Client{
Timeout: 60 * time.Second,
},
}
api.registerDefaultHandlers()