Documentation ¶
Index ¶
- type Helper
- func (h *Helper) Close()
- func (h *Helper) DeleteBroker(ctx context.Context, t *testing.T, brokerKey string)
- func (h *Helper) DeleteTarget(ctx context.Context, t *testing.T, targetKey string)
- func (h *Helper) GenerateBroker(ctx context.Context, t *testing.T, namespace string) *config.Broker
- func (h *Helper) GenerateTarget(ctx context.Context, t *testing.T, brokerKey string, filters map[string]string) *config.Target
- func (h *Helper) RenewBroker(ctx context.Context, t *testing.T, brokerKey string) *config.Broker
- func (h *Helper) RenewTarget(ctx context.Context, t *testing.T, targetKey string) *config.Target
- func (h *Helper) SendEventToDecoupleQueue(ctx context.Context, t *testing.T, brokerKey string, event *event.Event)
- func (h *Helper) SendEventToRetryQueue(ctx context.Context, t *testing.T, targetKey string, event *event.Event)
- func (h *Helper) VerifyAndRespondNextTargetEvent(ctx context.Context, t *testing.T, targetKey string, ...)
- func (h *Helper) VerifyNextBrokerIngressEvent(ctx context.Context, t *testing.T, brokerKey string, wantEvent *event.Event)
- func (h *Helper) VerifyNextTargetEvent(ctx context.Context, t *testing.T, targetKey string, wantEvent *event.Event)
- func (h *Helper) VerifyNextTargetEventAndDelayResp(ctx context.Context, t *testing.T, targetKey string, wantEvent *event.Event, ...)
- func (h *Helper) VerifyNextTargetRetryEvent(ctx context.Context, t *testing.T, targetKey string, wantEvent *event.Event)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Helper ¶
type Helper struct { // The test pubsub server. // PubsubServer.Messages can be called to retrieve all published raw // pubsub messages. PubsubServer *pstest.Server // The pubsub client connected to the test pubsub server. // Can be used to operate pubsub resources. PubsubClient *pubsub.Client // The cloudevents pubsub protocol backed by the test pubsub client. // Can be used to send/receive events from the test pubsub server. CePubsub *cepubsub.Protocol // The targets config maintained by this helper. Targets config.Targets // contains filtered or unexported fields }
Helper provides helper functions to facilitate handler pool testing.
func (*Helper) DeleteBroker ¶
DeleteBroker deletes the broker by key. It also cleans up test resources used by the broker.
func (*Helper) DeleteTarget ¶
DeleteTarget deletes a target and test resources used by it.
func (*Helper) GenerateBroker ¶
GenerateBroker generates a broker in the given namespace with random broker name. The following test resources will also be created. 1. The broker decouple topic and subscription. 2. The broker ingress server.
func (*Helper) GenerateTarget ¶
func (h *Helper) GenerateTarget(ctx context.Context, t *testing.T, brokerKey string, filters map[string]string) *config.Target
GenerateTarget generates a target for the broker with a random name. The following test resources will also be created: 1. The target retry topic/subscription. 2. The subscriber server.
func (*Helper) RenewBroker ¶
RenewBroker generates new test resources for an existing broker.
func (*Helper) RenewTarget ¶
RenewTarget generates new test resources for a target.
func (*Helper) SendEventToDecoupleQueue ¶
func (h *Helper) SendEventToDecoupleQueue(ctx context.Context, t *testing.T, brokerKey string, event *event.Event)
SendEventToDecoupleQueue sends the given event to the decouple queue of the given broker.
func (*Helper) SendEventToRetryQueue ¶
func (h *Helper) SendEventToRetryQueue(ctx context.Context, t *testing.T, targetKey string, event *event.Event)
SendEventToRetryQueue sends the given event to the retry queue of the given target.
func (*Helper) VerifyAndRespondNextTargetEvent ¶
func (h *Helper) VerifyAndRespondNextTargetEvent(ctx context.Context, t *testing.T, targetKey string, wantEvent, replyEvent *event.Event, statusCode int, delay time.Duration)
VerifyAndRespondNextTargetEvent verifies the next event the subscriber receives and replies with the given parameters. If wantEvent is nil, then it means such an event is not expected. This function is blocking and should be invoked in a separate goroutine with context timeout.
func (*Helper) VerifyNextBrokerIngressEvent ¶
func (h *Helper) VerifyNextBrokerIngressEvent(ctx context.Context, t *testing.T, brokerKey string, wantEvent *event.Event)
VerifyNextBrokerIngressEvent verifies the next event the broker ingress receives. If wantEvent is nil, then it means such an event is not expected. This function is blocking and should be invoked in a separate goroutine with context timeout.
func (*Helper) VerifyNextTargetEvent ¶
func (h *Helper) VerifyNextTargetEvent(ctx context.Context, t *testing.T, targetKey string, wantEvent *event.Event)
VerifyNextTargetEvent verifies the next event the subscriber receives. If wantEvent is nil, then it means such an event is not expected. This function is blocking and should be invoked in a separate goroutine with context timeout.
func (*Helper) VerifyNextTargetEventAndDelayResp ¶
func (h *Helper) VerifyNextTargetEventAndDelayResp(ctx context.Context, t *testing.T, targetKey string, wantEvent *event.Event, delay time.Duration)
VerifyNextTargetEventAndDelayResp verifies the next event the subscriber receives but not respond a success infinitely.
func (*Helper) VerifyNextTargetRetryEvent ¶
func (h *Helper) VerifyNextTargetRetryEvent(ctx context.Context, t *testing.T, targetKey string, wantEvent *event.Event)
VerifyNextTargetRetryEvent verifies the next event the target retry queue receives. Calling this function will also ack the next event. If wantEvent is nil, then it means such an event is not expected. This function is blocking and should be invoked in a separate goroutine with context timeout.