@@ -130,6 +130,46 @@ func (s *Rfc3164TestSuite) TestParseHeader_Valid(c *C) {
130
130
}
131
131
132
132
s .assertRfc3164Header (c , hdr , buff , 25 , nil )
133
+
134
+ // expected header for next two tests
135
+ hdr = header {
136
+ timestamp : time .Date (now .Year (), time .October , 1 , 22 , 14 , 15 , 0 , time .UTC ),
137
+ hostname : "mymachine" ,
138
+ }
139
+ // day with leading zero
140
+ buff = []byte ("Oct 01 22:14:15 mymachine " )
141
+ s .assertRfc3164Header (c , hdr , buff , 25 , nil )
142
+ // day with leading space
143
+ buff = []byte ("Oct 1 22:14:15 mymachine " )
144
+ s .assertRfc3164Header (c , hdr , buff , 25 , nil )
145
+
146
+ }
147
+
148
+ func (s * Rfc3164TestSuite ) TestParseHeader_RFC3339Timestamp (c * C ) {
149
+ buff := []byte ("2018-01-12T22:14:15+00:00 mymachine app[101]: msg" )
150
+ hdr := header {
151
+ timestamp : time .Date (2018 , time .January , 12 , 22 , 14 , 15 , 0 , time .UTC ),
152
+ hostname : "mymachine" ,
153
+ }
154
+ s .assertRfc3164Header (c , hdr , buff , 35 , nil )
155
+ }
156
+
157
+ func (s * Rfc3164TestSuite ) TestParser_ValidRFC3339Timestamp (c * C ) {
158
+ buff := []byte ("<34>2018-01-12T22:14:15+00:00 mymachine app[101]: msg" )
159
+ p := NewParser (buff )
160
+ err := p .Parse ()
161
+ c .Assert (err , IsNil )
162
+ obtained := p .Dump ()
163
+ expected := syslogparser.LogParts {
164
+ "timestamp" : time .Date (2018 , time .January , 12 , 22 , 14 , 15 , 0 , time .UTC ),
165
+ "hostname" : "mymachine" ,
166
+ "tag" : "app" ,
167
+ "content" : "msg" ,
168
+ "priority" : 34 ,
169
+ "facility" : 4 ,
170
+ "severity" : 2 ,
171
+ }
172
+ c .Assert (obtained , DeepEquals , expected )
133
173
}
134
174
135
175
func (s * Rfc3164TestSuite ) TestParseHeader_InvalidTimestamp (c * C ) {
0 commit comments