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

Function TestFillCreateRecordDefault

config_test.go:9–67  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func TestFillCreateRecordDefault(t *testing.T) {
10 tests := []struct {
11 name string
12 field string
13 want byte
14 wantErr bool
15 }{
16 {
17 name: "default",
18 field: "",
19 want: DefaultLogLineFieldSeparator,
20 },
21 {
22 name: "explicit comma",
23 field: ",",
24 want: DefaultLogLineFieldSeparator,
25 },
26 {
27 name: "record separator",
28 field: "\u001e",
29 want: 0x1e,
30 },
31 {
32 name: "dot",
33 field: ".",
34 want: '.',
35 },
36 {
37 name: "not ascii",
38 field: "à",
39 wantErr: true,
40 },
41 {
42 name: "2 chars",
43 field: ",,",
44 wantErr: true,
45 },
46 }
47 for _, tt := range tests {
48 t.Run(tt.name, func(t *testing.T) {
49 cfg := Config{
50 CSV: ConfigCSV{
51 FieldSeparator: tt.field,
52 },
53 }
54 err := cfg.fillCreateRecordDefault()
55 if tt.wantErr {
56 if err == nil {
57 t.Fatalf("Config.fillCreateRecordDefault() err: %v, wantErr: %v", err, tt.wantErr)
58 }
59 return
60 }
61
62 if sep := cfg.createRecord().(*LogLine).FieldSeparator; sep != tt.want {
63 t.Errorf(`got separator "%c" (%v), want "%c" (%v)`, sep, sep, tt.want, tt.want)
64 }
65 })
66 }

Callers

nothing calls this directly

Calls 2

RunMethod · 0.65

Tested by

no test coverage detected