Merged in feature/remove-query (pull request #201)
remove query from codebase part 1 * remove query * fix localstack run
This commit is contained in:
@@ -3,7 +3,6 @@ package test
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"log/slog"
|
||||
"regexp"
|
||||
"testing"
|
||||
@@ -112,55 +111,3 @@ func AssertMessageAttr(t testing.TB, cfg serviceconfig.ConfigProvider, url strin
|
||||
assert.NotNil(t, message.MessageAttributes[name])
|
||||
assert.Regexp(t, value, *(message.MessageAttributes[name]).StringValue)
|
||||
}
|
||||
|
||||
func AssertMessageBodies(t testing.TB, cfg serviceconfig.ConfigProvider, url string, bodies []*regexp.Regexp) {
|
||||
t.Helper()
|
||||
timeout := time.After(30 * time.Second)
|
||||
tick := time.NewTicker(2 * time.Second)
|
||||
defer tick.Stop()
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-timeout:
|
||||
t.Fatal("assert timeout")
|
||||
case <-tick.C:
|
||||
slog.Info("receiving from queue")
|
||||
|
||||
result, err := cfg.ReceiveFromQueue(t.Context(), &queue.ReceiveParams{
|
||||
QueueURL: url,
|
||||
VisibilityTimeout: 1,
|
||||
WaitTimeSeconds: 1,
|
||||
})
|
||||
if err != nil {
|
||||
continue
|
||||
} else if len(result.Messages) < 1 {
|
||||
continue
|
||||
}
|
||||
|
||||
found := true
|
||||
for _, m := range result.Messages {
|
||||
foundBody := false
|
||||
for _, b := range bodies {
|
||||
log.Print(*m.Body)
|
||||
if b.MatchString(*m.Body) {
|
||||
foundBody = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if !foundBody {
|
||||
found = false
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if !found {
|
||||
continue
|
||||
}
|
||||
|
||||
return
|
||||
case <-t.Context().Done():
|
||||
t.Fatal(t.Context().Err())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user