(t *testing.T)
| 38 | } |
| 39 | |
| 40 | func TestConsoleEncodeEntry(t *testing.T) { |
| 41 | tests := []struct { |
| 42 | desc string |
| 43 | expected string |
| 44 | ent Entry |
| 45 | fields []Field |
| 46 | }{ |
| 47 | { |
| 48 | desc: "info no fields", |
| 49 | expected: "2018-06-19T16:33:42Z\tinfo\tbob\tlob law\n", |
| 50 | ent: Entry{ |
| 51 | Level: InfoLevel, |
| 52 | Time: time.Date(2018, 6, 19, 16, 33, 42, 99, time.UTC), |
| 53 | LoggerName: "bob", |
| 54 | Message: "lob law", |
| 55 | }, |
| 56 | }, |
| 57 | { |
| 58 | desc: "zero_time_omitted", |
| 59 | expected: "info\tname\tmessage\n", |
| 60 | ent: Entry{ |
| 61 | Level: InfoLevel, |
| 62 | Time: time.Time{}, |
| 63 | LoggerName: "name", |
| 64 | Message: "message", |
| 65 | }, |
| 66 | }, |
| 67 | } |
| 68 | |
| 69 | cfg := testEncoderConfig() |
| 70 | cfg.EncodeTime = RFC3339TimeEncoder |
| 71 | enc := NewConsoleEncoder(cfg) |
| 72 | |
| 73 | for _, tt := range tests { |
| 74 | t.Run(tt.desc, func(t *testing.T) { |
| 75 | buf, err := enc.EncodeEntry(tt.ent, tt.fields) |
| 76 | if assert.NoError(t, err, "Unexpected console encoding error.") { |
| 77 | assert.Equal(t, tt.expected, buf.String(), "Incorrect encoded entry.") |
| 78 | } |
| 79 | buf.Free() |
| 80 | }) |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | func TestConsoleSeparator(t *testing.T) { |
| 85 | tests := []struct { |
nothing calls this directly
no test coverage detected