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

Function TestFileWriterConfig

output/filewriter_test.go:29–96  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

27)
28
29func TestFileWriterConfig(t *testing.T) {
30 if !testing.Verbose() {
31 defer testutil.LessLogging()()
32 }
33
34 tests := []struct {
35 name string
36 cfg *output.FileWriterConfig
37 fields []baker.FieldIndex
38 wantErr bool
39 }{
40 {
41 name: "all defaults",
42 cfg: &output.FileWriterConfig{},
43 },
44 {
45 name: "{{.Field0}} and len(output.fields) == 1",
46 cfg: &output.FileWriterConfig{
47 PathString: "/path/{{.Field0}}/file.gz",
48 },
49 fields: []baker.FieldIndex{0},
50 },
51 {
52 name: "{{.Field0}} and len(output.fields) > 1",
53 cfg: &output.FileWriterConfig{
54 PathString: "/path/{{.Field0}}/file.gz",
55 },
56 fields: []baker.FieldIndex{0, 1},
57 },
58
59 // error cases
60 {
61 name: "{{.Field0}} and len(output.fields) == 0",
62 cfg: &output.FileWriterConfig{
63 PathString: "/path/{{.Field0}}/file.gz",
64 },
65 fields: []baker.FieldIndex{},
66 wantErr: true,
67 },
68 {
69 name: "malformed template",
70 cfg: &output.FileWriterConfig{
71 PathString: "/path/{{.BadPattern}",
72 },
73 fields: []baker.FieldIndex{},
74 wantErr: true,
75 },
76 }
77
78 for _, tt := range tests {
79 t.Run(tt.name, func(t *testing.T) {
80 cfg := baker.OutputParams{
81 ComponentParams: baker.ComponentParams{
82 DecodedConfig: tt.cfg,
83 },
84 Fields: tt.fields,
85 }
86 _, err := output.NewFileWriter(cfg)

Callers

nothing calls this directly

Calls 3

LessLoggingFunction · 0.92
NewFileWriterFunction · 0.92
RunMethod · 0.65

Tested by

no test coverage detected