forked from tiaguinho/mercadolibre-go-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauth_test.go
45 lines (36 loc) · 887 Bytes
/
auth_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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package meli
import (
"fmt"
"reflect"
"testing"
)
var (
client = Client{
ClientID: 907054494590799,
ClientSecret: "x7qFo8AudrLHEsDWm96Kwfu1xbYTiWbW",
}
code = "your code"
redirectUrl = "redirect url"
)
//Test GetAuthUrl function
func TestGetAuthUrl(t *testing.T) {
result, _ := client.GetAuthUrl("", AuthUrls["MLB"])
expected := "https://auth.mercadolivre.com.br/authorization?client_id=907054494590799&redirect_uri=&response_type=code"
if reflect.DeepEqual(expected, result) == false {
t.Error(fmt.Sprintf("Expected: %s - Got: %s", expected, result))
}
}
//Test Authorize function
func TestAuthorize(t *testing.T) {
err := client.Authorize(code, redirectUrl)
if err != nil {
t.Error(err)
}
}
//Test RefreshAccessToken function
func TestRefreshAccessToken(t *testing.T) {
err := client.RefreshAccessToken()
if err != nil {
t.Error(err)
}
}