MCPcopy Create free account
hub / github.com/AdRoll/baker / testIntegrationSQS

Function testIntegrationSQS

input/sqs_test.go:355–437  ·  view source on GitHub ↗
(tc sqsIntegrationTestCase)

Source from the content-addressed store, hash-verified

353}
354
355func testIntegrationSQS(tc sqsIntegrationTestCase) func(t *testing.T) {
356 return func(t *testing.T) {
357 toml := `
358[fields]
359Names=["bucket", "path", "filename"]
360
361[csv]
362field_separator=","
363
364[input]
365Name="sqs"
366[input.config]
367Bucket=%q
368MessageFormat="plain"
369QueuePrefixes=[%v]
370QueueNames=[%v]
371FilePathFilter=".*"
372
373[output]
374Name="RawRecorder"
375Procs=1
376fields=["bucket", "path", "filename"]
377`
378
379 /* Configure the pipeline */
380 comp := baker.Components{
381 Inputs: []baker.InputDesc{SQSDesc},
382 Outputs: []baker.OutputDesc{outputtest.RawRecorderDesc},
383 }
384
385 prefixes := []string{}
386 for _, pref := range tc.queuePrefixes {
387 prefixes = append(prefixes, `"`+pref+`"`)
388 }
389 queues := []string{}
390 for _, name := range tc.queueNames {
391 queues = append(queues, `"`+name+`"`)
392 }
393
394 r := strings.NewReader(fmt.Sprintf(toml, tc.bucket, strings.Join(prefixes, ","), strings.Join(queues, ",")))
395 cfg, err := baker.NewConfigFromToml(r, comp)
396 if err != nil {
397 t.Fatal(err)
398 }
399
400 topo, err := baker.NewTopologyFromConfig(cfg)
401 if err != nil {
402 t.Fatal(err)
403 }
404
405 // Replace aws services interfaces with mocks.
406 topo.Input.(*SQS).svc = &mockSQSClient{
407 queues: tc.messages,
408 }
409 topo.Input.(*SQS).s3Input.SetS3API(newMockedS3FromFS(os.DirFS("testdata/sqstest")))
410
411 /* Run the pipeline */
412 topo.Start()

Callers 1

TestSQSFunction · 0.85

Calls 8

NewConfigFromTomlFunction · 0.92
NewTopologyFromConfigFunction · 0.92
newMockedS3FromFSFunction · 0.85
SetS3APIMethod · 0.80
StopMethod · 0.65
StartMethod · 0.45
WaitMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected