package automation

import (
	"testing"

	"github.com/pingcap-inc/nexuscrm-contract/pkg/approvalir"
)

type dormantApprovalDefinitionDecoder struct{}

func (*dormantApprovalDefinitionDecoder) DecodeApprovalDefinition(string) (*approvalir.Definition, error) {
	panic("dormant decoder must not be called by service construction")
}

func TestWithApprovalDefinitionDecoderStoresDecoder(t *testing.T) {
	decoder := &dormantApprovalDefinitionDecoder{}
	svc := NewApprovalService(nil, nil, nil, nil, nil, nil, nil, nil, WithApprovalDefinitionDecoder(decoder))
	if svc.approvalDefinitionDecoder != decoder {
		t.Fatal("WithApprovalDefinitionDecoder did not preserve the supplied decoder")
	}
}
