48 lines
979 B
Go
48 lines
979 B
Go
|
|
package queue_test
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
"queryorchestration/internal/queue"
|
||
|
|
"testing"
|
||
|
|
"time"
|
||
|
|
|
||
|
|
"github.com/aws/aws-sdk-go-v2/service/sqs/types"
|
||
|
|
"github.com/stretchr/testify/assert"
|
||
|
|
)
|
||
|
|
|
||
|
|
type MockController struct{}
|
||
|
|
|
||
|
|
func (s MockController) Process(ctx context.Context, config *queue.Config, msg *types.Message) error {
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
|
||
|
|
func TestPollMessages(t *testing.T) {
|
||
|
|
ctx := context.Background()
|
||
|
|
queueConfig, cleanup := createQueue(t, ctx)
|
||
|
|
defer cleanup()
|
||
|
|
|
||
|
|
controller := MockController{}
|
||
|
|
|
||
|
|
ctx, cancel := context.WithTimeout(ctx, time.Second)
|
||
|
|
defer cancel()
|
||
|
|
|
||
|
|
queue.PollMessages(ctx, &queue.PollConfig{
|
||
|
|
Config: queueConfig.Config,
|
||
|
|
Controller: controller,
|
||
|
|
})
|
||
|
|
}
|
||
|
|
|
||
|
|
func TestPollMessage(t *testing.T) {
|
||
|
|
ctx := context.Background()
|
||
|
|
queueConfig, cleanup := createQueue(t, ctx)
|
||
|
|
defer cleanup()
|
||
|
|
|
||
|
|
controller := MockController{}
|
||
|
|
|
||
|
|
err := queue.PollMessage(ctx, &queue.PollConfig{
|
||
|
|
Config: queueConfig.Config,
|
||
|
|
Controller: controller,
|
||
|
|
})
|
||
|
|
assert.Nil(t, err)
|
||
|
|
}
|