package ocr

import (
	"context"
	_ "embed"
	"net/http"
	"path/filepath"
	"testing"

	"go.uber.org/zap"
)

//go:embed testdata/b64.txt
var b64 string

func TestA(t *testing.T) {
	// os.Setenv("HTTPS_PROXY", "http://127.0.0.1:9000")
	// os.Setenv("HTTP_PROXY", "http://127.0.0.1:9000")
	logger := zap.NewNop()
	// logger, _ = zap.NewDevelopment()

	cli := OcrClient{
		Option:  DefaultOcrOption,
		Client:  http.DefaultClient,
		Logger:  logger,
		BaseURL: DefaultOcrURL,
	}

	ctx := context.Background()

	code1, err := cli.GetCaptchaCodeURL(ctx, b64)
	if err != nil {
		t.Fatal(err)
	}
	if code1 != "v140" {
		t.Fatalf("code not match %s", code1)
	}

	imgPath := filepath.Join("testdata", "v140.png")
	code2, err := cli.GetCaptchaCodePath(ctx, imgPath)
	if err != nil {
		t.Fatal(err)
	}
	if code2 != "v140" {
		t.Fatalf("code not match %s", code2)
	}
}
