package template_display

import (
	"log"
	"os"
	"testing"
	"user-behavior/pkg/feishu"
	"user-behavior/pkg/model"

	"github.com/spf13/viper"
)

func TestTemplateBackupTooLong(t *testing.T) {
	setUpConfig()
	os.Chdir("../..")
	params := BackupTemplateParams{
		TenantName:      "Test Tenant",
		Region:          "CO",
		TenantId:        100,
		ClusterId:       100,
		BackupId:        100,
		BackupStatus:    "done",
		ErrorMessage:    "",
		BackupType:      "auto",
		IsFailed:        false,
		Size:            "100MiB",
		CorrelatedIssue: "[O11Y-50542](https://jira.tidbcloud.com/projects/O11Y/issues/O11Y-50542)",
	}
	text, err := GenerateText(BackupFinish, params)
	if err != nil {
		log.Println(err)
	} else {
		log.Println(text)
	}
	feishu.SendCardToInternalReportChat(model.FeishuCardParams{Title: "test", Color: "red", Text: text})
}

func setUpConfig() {
	viper.Set("scope", "prod")
	viper.SetConfigName("conf")         // name of config file (without extension)
	viper.SetConfigType("yaml")         // REQUIRED if the config file does not have the extension in the name
	viper.AddConfigPath("../../config") // optionally look for config in the working directory
	viper.ReadInConfig()
	log.Println(viper.GetString("jira_token.tcoc_token"))
}
