7
7
"context"
8
8
"fmt"
9
9
"testing"
10
+ "time"
10
11
11
12
"github.com/stretchr/testify/mock"
12
13
"github.com/stretchr/testify/require"
@@ -92,7 +93,8 @@ func TestTransformerDropOnError(t *testing.T) {
92
93
}
93
94
ctx := context .Background ()
94
95
testEntry := entry .New ()
95
- testEntry .Body = "test"
96
+ now := time .Now ()
97
+ testEntry .Timestamp = now
96
98
testEntry .AddAttribute (attrs .LogFilePath , "/test/file" )
97
99
transform := func (_ * entry.Entry ) error {
98
100
return fmt .Errorf ("Failure" )
@@ -108,7 +110,7 @@ func TestTransformerDropOnError(t *testing.T) {
108
110
Entry : zapcore.Entry {Level : zap .ErrorLevel , Message : "Failed to process entry" },
109
111
Context : []zapcore.Field {
110
112
zap .Any (attrs .LogFilePath , "/test/file" ),
111
- zap .Any (attrs . LogRecordOriginal , "test" ),
113
+ zap .Any ("entry.timestamp" , now ),
112
114
{Key : "error" , Type : zapcore .ErrorType , Interface : fmt .Errorf ("Failure" )},
113
115
zap .Any ("action" , "drop" ),
114
116
},
@@ -141,7 +143,8 @@ func TestTransformerDropOnErrorQuiet(t *testing.T) {
141
143
}
142
144
ctx := context .Background ()
143
145
testEntry := entry .New ()
144
- testEntry .Body = "test"
146
+ now := time .Now ()
147
+ testEntry .Timestamp = now
145
148
testEntry .AddAttribute (attrs .LogFilePath , "/test/file" )
146
149
transform := func (_ * entry.Entry ) error {
147
150
return fmt .Errorf ("Failure" )
@@ -157,7 +160,7 @@ func TestTransformerDropOnErrorQuiet(t *testing.T) {
157
160
Entry : zapcore.Entry {Level : zap .DebugLevel , Message : "Failed to process entry" },
158
161
Context : []zapcore.Field {
159
162
zap .Any (attrs .LogFilePath , "/test/file" ),
160
- zap .Any (attrs . LogRecordOriginal , "test" ),
163
+ zap .Any ("entry.timestamp" , now ),
161
164
{Key : "error" , Type : 26 , Interface : fmt .Errorf ("Failure" )},
162
165
zap .Any ("action" , "drop_quiet" ),
163
166
},
@@ -190,7 +193,8 @@ func TestTransformerSendOnError(t *testing.T) {
190
193
}
191
194
ctx := context .Background ()
192
195
testEntry := entry .New ()
193
- testEntry .Body = "test"
196
+ now := time .Now ()
197
+ testEntry .Timestamp = now
194
198
testEntry .AddAttribute (attrs .LogFilePath , "/test/file" )
195
199
transform := func (_ * entry.Entry ) error {
196
200
return fmt .Errorf ("Failure" )
@@ -206,7 +210,7 @@ func TestTransformerSendOnError(t *testing.T) {
206
210
Entry : zapcore.Entry {Level : zap .ErrorLevel , Message : "Failed to process entry" },
207
211
Context : []zapcore.Field {
208
212
zap .Any (attrs .LogFilePath , "/test/file" ),
209
- zap .Any (attrs . LogRecordOriginal , "test" ),
213
+ zap .Any ("entry.timestamp" , now ),
210
214
{Key : "error" , Type : 26 , Interface : fmt .Errorf ("Failure" )},
211
215
zap .Any ("action" , "send" ),
212
216
},
@@ -239,7 +243,8 @@ func TestTransformerSendOnErrorQuiet(t *testing.T) {
239
243
}
240
244
ctx := context .Background ()
241
245
testEntry := entry .New ()
242
- testEntry .Body = "test"
246
+ now := time .Now ()
247
+ testEntry .Timestamp = now
243
248
testEntry .AddAttribute (attrs .LogFilePath , "/test/file" )
244
249
transform := func (_ * entry.Entry ) error {
245
250
return fmt .Errorf ("Failure" )
@@ -255,7 +260,7 @@ func TestTransformerSendOnErrorQuiet(t *testing.T) {
255
260
Entry : zapcore.Entry {Level : zap .DebugLevel , Message : "Failed to process entry" },
256
261
Context : []zapcore.Field {
257
262
zap .Any (attrs .LogFilePath , "/test/file" ),
258
- zap .Any (attrs . LogRecordOriginal , "test" ),
263
+ zap .Any ("entry.timestamp" , now ),
259
264
{Key : "error" , Type : 26 , Interface : fmt .Errorf ("Failure" )},
260
265
zap .Any ("action" , "send_quiet" ),
261
266
},
0 commit comments