package order

import (
	"context"
	"testing"

	"github.com/perfect-panel/server/internal/svc"
	"github.com/perfect-panel/server/internal/types"
	"github.com/perfect-panel/server/pkg/logger"
	"github.com/perfect-panel/server/pkg/xerr"
)

func TestUpdateOrderStatus_RejectsRefundStatus(t *testing.T) {
	logic := &UpdateOrderStatusLogic{
		Logger: logger.WithContext(context.Background()),
		ctx:    context.Background(),
		svcCtx: &svc.ServiceContext{},
	}

	for _, status := range []uint8{orderStatusClaimed, orderStatusRefunded} {
		err := logic.UpdateOrderStatus(&types.UpdateOrderStatusRequest{
			Id:     1001,
			Status: status,
		})
		if !isErrCode(err, xerr.OrderStatusError) {
			t.Fatalf("status %d: UpdateOrderStatus error code = %v, want OrderStatusError; raw=%v", status, errCodeOf(err), err)
		}
	}
}
