-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhttp_test.go
29 lines (25 loc) · 924 Bytes
/
http_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package provider_test
import (
"testing"
"github.com/kbukum/dataprovider"
"github.com/stretchr/testify/assert"
)
func TestHttpProvider_Get(t *testing.T) {
p, err := provider.HttpProviderFactory()
// create provider
assert.Nil(t, err, "Couldn't create provider Error: %v", err)
// get file by http provider
result, contentType, err := p.Get("https://www.google.com.tr/logos/2017/hiphop/cta_bg.jpg")
assert.Nil(t, err, "Error is not null")
assert.Equal(t, ".jpg", contentType, "ContentType must be .jpg")
assert.NotNil(t, result, "Content is nil ")
// get file by http provider
result, contentType, err = p.Get(&provider.HttpInput{
Method: "GET",
Url: "https://www.google.com.tr/logos/2017/hiphop/cta_bg.jpg",
Headers: map[string]string{},
})
assert.Nil(t, err, "Error is not null")
assert.Equal(t, ".jpg", contentType, "ContentType must be .jpg")
assert.NotNil(t, result, "Content is nil ")
}