package tests

import (
	"context"
	"crypto/tls"
	"fmt"
	"gitea.pena/SQuiz/common/model"
	"gitea.pena/SQuiz/worker/internal/clients/gigachat"
	"github.com/go-redis/redis/v8"
	"github.com/go-resty/resty/v2"
	"go.uber.org/zap"
	"testing"
	"time"
)

func TestGigachat(t *testing.T) {
	ctx := context.Background()
	logger, _ := zap.NewDevelopment()

	redisClient := redis.NewClient(&redis.Options{
		Addr:     "localhost:6379",
		Password: "admin",
		DB:       2,
	})

	gigaChatClient, err := gigachat.NewGigaChatClient(ctx, gigachat.Deps{
		Logger:      logger,
		Client:      resty.New().SetTLSClientConfig(&tls.Config{InsecureSkipVerify: true}),
		BaseURL:     "https://gigachat.devices.sberbank.ru/api/v1",
		AuthKey:     "ZGM3MDY0ZjAtODM4Yi00ZTQ4LTgzMTgtZDA0ZDA3NmIwYzJjOjRkZWI4Y2NhLTc1YzUtNDg5ZS04YzY4LTVkNTdmMWU1YjU5Nw==",
		RedisClient: redisClient,
	})
	if err != nil {
		panic(err)
	}

	go gigaChatClient.TokenResearch(ctx)

	result, err := gigaChatClient.SendMsg(ctx, model.GigaChatAudience{
		Sex: 1,
		Age: "17-23",
	}, model.Question{
		Title:       "О личной жизни",
		Description: "Как много у вас котят?",
	})
	if err != nil {
		panic(err)
	}

	fmt.Println(result)

	time.Sleep(10 * time.Minute)
}
