package datares

import (
	"fmt"
	"testing"

	"git.rosy.net.cn/baseapi/utils"
	"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
	"git.rosy.net.cn/jx-callback/business/model"
	"git.rosy.net.cn/jx-callback/globals/api2"
	"git.rosy.net.cn/jx-callback/globals/testinit"

	_ "git.rosy.net.cn/jx-callback/business/partner/purchase/ebai"
	_ "git.rosy.net.cn/jx-callback/business/partner/purchase/jd"
	_ "git.rosy.net.cn/jx-callback/business/partner/purchase/mtwm"
)

func init() {
	testinit.Init()
	api2.Init()
}

func TestGetQiniuUploadToken(t *testing.T) {
	token, err := GetQiniuUploadToken(jxcontext.AdminCtx, "", "")
	if err != nil {
		t.Fatal(err)
	}
	fmt.Print(token)
}

func TestGetDataResource(t *testing.T) {
	dataRes, err := GetDataResource(jxcontext.AdminCtx, "1D3E4A8259F359FB4CF47D541843950D")
	if err != nil {
		t.Fatal(err)
	}
	t.Log(utils.Format4Output(dataRes, false))
}

func TestTryRegisterDataResource(t *testing.T) {
	dataRes, err := TryRegisterDataResource(jxcontext.AdminCtx, "test", "http://image.jxc4.com/image/37db6b94925e669e0a7b6844ba7ce160.jpg", model.ImgTypeMain, false)
	if err != nil {
		t.Fatal(err)
	}
	t.Log(utils.Format4Output(dataRes, false))
}
