package camel_oil

import (
	_ "github.com/gogf/gf/contrib/drivers/mysql/v2"
	_ "github.com/gogf/gf/contrib/nosql/redis/v2"
	"github.com/gogf/gf/v2/os/gctx"
	"github.com/gogf/gf/v2/os/gtime"
	"kami/internal/logic/proxy_pool"
	"kami/internal/service"
	"testing"
	"time"
)

func Test_sCamelOil_PrefetchOrderConcurrently(t *testing.T) {
	service.RegisterProxyPool(proxy_pool.New())
	_ = service.ProxyPool().InitStrategy(gctx.GetInitCtx(), "https://share.proxy.qg.net/get?key=E4WS5YZV&num=1&area=&isp=0&format=txt&seq=\\r\\n&distinct=false", gtime.M)
	ticker := time.Tick(time.Second * 3)
	start := time.Now()
	for range ticker {
		result, _ := (&sCamelOil{}).PrefetchOrderConcurrently(t.Context(), 100)
		if result != nil {
			t.Logf("result: %+v", result)
			break
		}
		if time.Now().Sub(start) >= time.Minute*5 {
			break
		}
	}
}

func Test_sCamelOil_MatchPrefetchOrder(t *testing.T) {
	now := gtime.Now()
	timeKey := now.Layout("2006-01-02T15:04")
	t.Log(timeKey)

	//result, err := (&sCamelOil{}).MatchPrefetchOrder(t.Context(), utils.GenerateRandomUUID(), 100)
	//if err != nil {
	//	t.Error(err)
	//}
	//t.Log(result)
}
