Files
query-orchestration/internal/server/queue/poll_test.go
T
Michael McGuinness fa95d733ca Merged in feature/shorttestsanddirtidy (pull request #26)
Add short tests and Tidy internal directories

* complete the tasks
2025-01-17 12:00:32 +00:00

63 lines
1.3 KiB
Go

package queue_test
import (
"context"
"queryorchestration/internal/server/queue"
"queryorchestration/internal/test"
"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) {
if testing.Short() {
t.Skip("Skipping long test in short mode")
}
ctx := context.Background()
queueConfig, cleanup := test.CreateQueue(t, ctx, &test.CreateQueueConfig{})
defer cleanup()
controller := MockController{}
ctx, cancel := context.WithTimeout(ctx, time.Second)
defer cancel()
cfg := &queue.Config{
URL: queueConfig.URL,
Client: queueConfig.Client,
}
queue.PollMessages(ctx, &queue.PollConfig{
Config: cfg,
Controller: controller,
})
}
func TestPollMessage(t *testing.T) {
if testing.Short() {
t.Skip("Skipping long test in short mode")
}
ctx := context.Background()
queueConfig, cleanup := test.CreateQueue(t, ctx, &test.CreateQueueConfig{})
defer cleanup()
controller := MockController{}
cfg := &queue.Config{
URL: queueConfig.URL,
Client: queueConfig.Client,
}
err := queue.PollMessage(ctx, &queue.PollConfig{
Config: cfg,
Controller: controller,
})
assert.Nil(t, err)
}