(t *testing.T)
| 82 | } |
| 83 | |
| 84 | func TestConsoleSeparator(t *testing.T) { |
| 85 | tests := []struct { |
| 86 | desc string |
| 87 | separator string |
| 88 | wantConsole string |
| 89 | }{ |
| 90 | { |
| 91 | desc: "space console separator", |
| 92 | separator: " ", |
| 93 | wantConsole: "0 info main foo.go:42 foo.Foo hello\nfake-stack\n", |
| 94 | }, |
| 95 | { |
| 96 | desc: "default console separator", |
| 97 | separator: "", |
| 98 | wantConsole: "0\tinfo\tmain\tfoo.go:42\tfoo.Foo\thello\nfake-stack\n", |
| 99 | }, |
| 100 | { |
| 101 | desc: "tag console separator", |
| 102 | separator: "\t", |
| 103 | wantConsole: "0\tinfo\tmain\tfoo.go:42\tfoo.Foo\thello\nfake-stack\n", |
| 104 | }, |
| 105 | { |
| 106 | desc: "dash console separator", |
| 107 | separator: "--", |
| 108 | wantConsole: "0--info--main--foo.go:42--foo.Foo--hello\nfake-stack\n", |
| 109 | }, |
| 110 | } |
| 111 | |
| 112 | for _, tt := range tests { |
| 113 | console := NewConsoleEncoder(encoderTestEncoderConfig(tt.separator)) |
| 114 | t.Run(tt.desc, func(t *testing.T) { |
| 115 | entry := testEntry |
| 116 | consoleOut, err := console.EncodeEntry(entry, nil) |
| 117 | if !assert.NoError(t, err) { |
| 118 | return |
| 119 | } |
| 120 | assert.Equal( |
| 121 | t, |
| 122 | tt.wantConsole, |
| 123 | consoleOut.String(), |
| 124 | "Unexpected console output", |
| 125 | ) |
| 126 | }) |
| 127 | |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | func encoderTestEncoderConfig(separator string) EncoderConfig { |
| 132 | testEncoder := testEncoderConfig() |
nothing calls this directly
no test coverage detected