package test

import (
	"ColdVerify_server/lib/albb"
	"fmt"
	"os/exec"
	"strings"
	"testing"
)

func TestBeego(t *testing.T) {
	data := "001,69000000001|002,69000000002|001,69000000001|003,69000000003|"

	// 根据 | 分割数据
	items := strings.Split(data, "|")

	// 创建一个 map 来去重
	uniqueItems := make(map[string]struct{})

	for _, item := range items {
		// 如果不为空，则添加到 map 中
		if item != "" {
			uniqueItems[item] = struct{}{}
		}
	}

	// 将唯一项拼接成字符串
	result := ""

	for item := range uniqueItems {
		result += item + "|"
	}

	// 移除最后的 | 字符
	if len(result) > 0 {
		result = result[:len(result)-1]
	}

	fmt.Println(result)

}

func TestR(t *testing.T) {
	// 设置要执行的Python脚本和参数
	scriptPath := "../script"
	arg1 := "/Users/zoie/work/study/python/project/python2wordpdf_process-master/input.pdf"
	arg2 := "../ofile/watermarked.pdf"
	arg3 := "../script/watermark.pdf"

	// 执行Python脚本
	cmd := exec.Command("python", "add_watermark.py", arg1, arg2, arg3)
	cmd.Dir = scriptPath
	// 获取命令输出
	output, err := cmd.CombinedOutput()
	if err != nil {
		fmt.Println("Error:", err)
		//return
	}

	// 打印Python脚本的输出
	fmt.Println(string(output))
}

func TestDescribeInstances(t *testing.T) {
	albb.DescribeInstances()
}
