15adaebfcd
DRAFT PR : WIP working through ideas for integration * movearound * attempttwo * openapi * further sanding * fix * start on tests * runthroughsingleconfig * somechanges * reflectissue * removeerrs * mostlyremovepanic * removeenv * noncfgtests * go * repo * fix service config test * add PWD to all * test fix * fix lint * todo for later * passingunittests * alltests * testlogger * testloggername * clean
59 lines
1.2 KiB
Go
59 lines
1.2 KiB
Go
package runner
|
|
|
|
import (
|
|
"context"
|
|
"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, req *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 := &Server{
|
|
controller: &controller,
|
|
queueURL: queueConfig.URL,
|
|
client: queueConfig.Client,
|
|
cleanup: func() error { return nil },
|
|
}
|
|
cfg.Listen(ctx)
|
|
}
|
|
|
|
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 := &Server{
|
|
controller: &controller,
|
|
queueURL: queueConfig.URL,
|
|
client: queueConfig.Client,
|
|
}
|
|
err := cfg.pollMessage(ctx)
|
|
assert.Nil(t, err)
|
|
}
|