flamingo.me/flamingo-commerce/v3@v3.11.0/checkout/domain/placeorder/states/validate_payment_test.go (about)

     1  package states_test
     2  
     3  import (
     4  	"context"
     5  	"testing"
     6  
     7  	"flamingo.me/flamingo-commerce/v3/checkout/domain/placeorder/process"
     8  	"flamingo.me/flamingo-commerce/v3/checkout/domain/placeorder/states"
     9  	"flamingo.me/flamingo-commerce/v3/payment/application"
    10  
    11  	"github.com/stretchr/testify/assert"
    12  )
    13  
    14  func TestValidatePayment_IsFinal(t *testing.T) {
    15  	assert.False(t, states.ValidatePayment{}.IsFinal())
    16  }
    17  
    18  func TestValidatePayment_Name(t *testing.T) {
    19  	assert.Equal(t, "ValidatePayment", states.ValidatePayment{}.Name())
    20  }
    21  
    22  func TestValidatePayment_Rollback(t *testing.T) {
    23  	s := states.ValidatePayment{}
    24  	assert.Nil(t, s.Rollback(context.Background(), nil))
    25  }
    26  
    27  func TestValidatePayment_Run(t *testing.T) {
    28  	s := states.ValidatePayment{}
    29  	isCalled := false
    30  	s.Inject(nil, func(_ context.Context, _ *process.Process, _ *application.PaymentService) process.RunResult {
    31  		isCalled = true
    32  		return process.RunResult{}
    33  	})
    34  
    35  	s.Run(context.Background(), nil)
    36  
    37  	assert.True(t, isCalled)
    38  }