-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathoceanengine_test.go
35 lines (32 loc) · 922 Bytes
/
oceanengine_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
package oceanengine
import (
"context"
"github.com/antihax/optional"
"github.com/cuckooemm/oceanengine/ads"
"github.com/cuckooemm/oceanengine/api"
"github.com/cuckooemm/oceanengine/models"
"os"
"testing"
)
func TestInit(t *testing.T) {
adClient := ads.Init(true)
adClient.UseProduction()
adClient.Cfg.SetAccessToken("token")
adClient.Cfg.SetUserAgent("golang sdk")
apiLog, _ := os.OpenFile("api.log", os.O_CREATE|os.O_APPEND|os.O_RDWR, 0644)
defer apiLog.Close()
adClient.AppendMiddleware(ads.NewLogMiddleware(adClient, apiLog))
param := models.AdAdGetOpts{}
param.PageSize = optional.NewInt64(100)
rsp, header, err := adClient.Client.AdApi.Get(context.Background(), 123456789, param)
if err != nil {
e := err.(api.SwaggerError)
t.Log(e.Code())
t.Log(e.Body())
t.Log(e.Error())
t.Log(e.Message())
t.Log(e.RequestId())
}
t.Logf("response: %+v\n", rsp)
t.Logf("headers: %+v\n", header)
}