package xiaowmapi

import (
	"testing"

	"git.rosy.net.cn/baseapi"

	"go.uber.org/zap"
)

var (
	api         *API
	sugarLogger *zap.SugaredLogger
)

func init() {
	logger, _ := zap.NewDevelopment()
	sugarLogger = logger.Sugar()
	baseapi.Init(sugarLogger)

	api = New(267, "94337")
}

func TestPrinterAuth(t *testing.T) {
	result, err := api.AuthPrinter("notexist", "", "")
	if err != nil {
		t.Fatalf("PrinterAuth return error:%v", err)
	}
	t.Log(result)
}

func TestPrinterDel(t *testing.T) {
	err := api.DelPrinter("7JizmSyiXNzkggaqU", "177f213277dd842ba2b53f6c926a48ea")
	if err != nil {
		t.Fatalf("PrinterDel return error:%v", err)
	}
}

func TestSendMsg(t *testing.T) {
	result, err := api.SendMsg("7JizmSyiXNzkggaqU", "177f213277dd842ba2b53f6c926a48ea", "hello")
	if err != nil {
		t.Fatalf("SendMsg return error:%v", err)
	}
	t.Log(result)
}

func TestGetPrinterStatus(t *testing.T) {
	runningStae, paperState, err := api.GetPrinterStatus("notexist", "fc613a8811f963debca940c76b75d162")
	if err != nil {
		t.Fatalf("GetPrinterStatus return error:%v", err)
	}
	t.Log(runningStae, paperState)
}

func TestGetMsgStatus(t *testing.T) {
	msgStatus, err := api.GetMsgStatus("7JizmSyiXNzkggaqU", "177f213277dd842ba2b53f6c926a48ea", "29F953F9C26C4E2D7FD1279634C72ADD")
	if err != nil {
		t.Fatalf("GetMsgStatus return error:%v", err)
	}
	t.Log(msgStatus)
}
