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

Function testFileWriterIntegration

output/filewriter_test.go:373–422  ·  view source on GitHub ↗
(t *testing.T, tmpDir, pathString string, procs int, rotate time.Duration)

Source from the content-addressed store, hash-verified

371}
372
373func testFileWriterIntegration(t *testing.T, tmpDir, pathString string, procs int, rotate time.Duration) []string {
374 // This test uses a randomly generated input CSV file.
375 // schema: pick(AAA|BBB|CCC|DDD), digit(22), first, last, email, state
376 // site: https://www.convertcsv.com/generate-test-data.htm
377
378 toml := `
379 [fields]
380 names = ["kind", "digits", "first", "last", "email", "state"]
381
382 [input]
383 name = "list"
384
385 [input.config]
386 files = ["./testdata/filewriter/input.csv.log.zst"]
387
388 [output]
389 fields = ["kind"]
390 name = "filewriter"
391 procs = %d
392 [output.config]
393 pathstring = %q
394 rotateinterval = %q
395`
396 if !testing.Verbose() {
397 defer testutil.LessLogging()()
398 }
399
400 toml = fmt.Sprintf(toml, procs, strings.Replace(pathString, "TMPDIR", tmpDir, -1), rotate)
401
402 cfg, err := baker.NewConfigFromToml(strings.NewReader(toml),
403 baker.Components{
404 Inputs: []baker.InputDesc{input.ListDesc},
405 Outputs: []baker.OutputDesc{output.FileWriterDesc},
406 })
407 if err != nil {
408 t.Fatal(err)
409 }
410 topo, err := baker.NewTopologyFromConfig(cfg)
411 if err != nil {
412 t.Fatal(err)
413 }
414
415 topo.Start()
416 topo.Wait()
417
418 // We decompress files since the content of compressed files is not
419 // guaranteed to be determinsitic, however it's lossless so we'll use the
420 // decompressed file to control the files the output produced.
421 return decompressFilesInDir(t, tmpDir)
422}
423
424func TestFileWriterIntegrationField0(t *testing.T) {
425 testFileWriterIntegrationDeterministic(t, filepath.Join("TMPDIR", "{{.Field0}}", "out.csv.zst"))

Calls 6

LessLoggingFunction · 0.92
NewConfigFromTomlFunction · 0.92
NewTopologyFromConfigFunction · 0.92
decompressFilesInDirFunction · 0.85
StartMethod · 0.45
WaitMethod · 0.45

Tested by

no test coverage detected