Merged in feature/queuetest (pull request #14)
Add tests for queuing * startingtest * queuerunnertest * addedtestfuncs * testtests * passintegration * unittests
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
package test_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"queryorchestration/internal/queue"
|
||||
"queryorchestration/internal/test"
|
||||
"testing"
|
||||
|
||||
"github.com/aws/aws-sdk-go-v2/aws"
|
||||
"github.com/aws/aws-sdk-go-v2/service/sqs/types"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestCreateQueue(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
qcfg, cleanup := test.CreateQueue(t, ctx, &test.CreateQueueConfig{})
|
||||
assert.NotNil(t, qcfg)
|
||||
assert.NotNil(t, cleanup)
|
||||
|
||||
cleanup()
|
||||
}
|
||||
|
||||
func TestAssertMessageWait(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
qcfg, cleanup := test.CreateQueue(t, ctx, &test.CreateQueueConfig{})
|
||||
defer cleanup()
|
||||
|
||||
cfg := &queue.Config{
|
||||
URL: qcfg.URL,
|
||||
Client: qcfg.Client,
|
||||
}
|
||||
|
||||
err := queue.Send(ctx, cfg, "body", map[string]types.MessageAttributeValue{})
|
||||
assert.Nil(t, err)
|
||||
|
||||
msg := test.AssertMessageWait(t, ctx, cfg, []string{})
|
||||
assert.NotNil(t, msg)
|
||||
}
|
||||
|
||||
func TestAssertMessageBodyWait(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
qcfg, cleanup := test.CreateQueue(t, ctx, &test.CreateQueueConfig{})
|
||||
defer cleanup()
|
||||
|
||||
cfg := &queue.Config{
|
||||
URL: qcfg.URL,
|
||||
Client: qcfg.Client,
|
||||
}
|
||||
|
||||
err := queue.Send(ctx, cfg, "body", map[string]types.MessageAttributeValue{})
|
||||
assert.Nil(t, err)
|
||||
|
||||
test.AssertMessageBodyWait(t, ctx, cfg, "\"body\"")
|
||||
}
|
||||
|
||||
func TestAssertMessageAttrWait(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
qcfg, cleanup := test.CreateQueue(t, ctx, &test.CreateQueueConfig{})
|
||||
defer cleanup()
|
||||
|
||||
cfg := &queue.Config{
|
||||
URL: qcfg.URL,
|
||||
Client: qcfg.Client,
|
||||
}
|
||||
|
||||
name := "name"
|
||||
value := "value"
|
||||
|
||||
err := queue.Send(ctx, cfg, "body", map[string]types.MessageAttributeValue{
|
||||
name: {
|
||||
DataType: aws.String("String"),
|
||||
StringValue: aws.String(value),
|
||||
},
|
||||
})
|
||||
assert.Nil(t, err)
|
||||
|
||||
test.AssertMessageAttrWait(t, ctx, cfg, name, value)
|
||||
}
|
||||
Reference in New Issue
Block a user