@@ -14,7 +14,13 @@ func Test(t *testing.T) { TestingT(t) }
14
14
type Rfc3164TestSuite struct {
15
15
}
16
16
17
- var _ = Suite (& Rfc3164TestSuite {})
17
+ var (
18
+ _ = Suite (& Rfc3164TestSuite {})
19
+
20
+ // XXX : corresponds to the length of the last tried timestamp format
21
+ // XXX : Jan 2 15:04:05
22
+ lastTriedTimestampLen = 14
23
+ )
18
24
19
25
func (s * Rfc3164TestSuite ) TestParser_Valid (c * C ) {
20
26
buff := []byte ("<34>Oct 11 22:14:15 mymachine su: 'su root' failed for lonvick on /dev/pts/8" )
@@ -62,7 +68,7 @@ func (s *Rfc3164TestSuite) TestParseHeader_InvalidTimestamp(c *C) {
62
68
buff := []byte ("Oct 34 32:72:82 mymachine " )
63
69
hdr := header {}
64
70
65
- s .assertRfc3164Header (c , hdr , buff , 16 , syslogparser .ErrTimestampUnknownFormat )
71
+ s .assertRfc3164Header (c , hdr , buff , lastTriedTimestampLen , syslogparser .ErrTimestampUnknownFormat )
66
72
}
67
73
68
74
func (s * Rfc3164TestSuite ) TestParsemessage_Valid (c * C ) {
@@ -76,19 +82,11 @@ func (s *Rfc3164TestSuite) TestParsemessage_Valid(c *C) {
76
82
s .assertRfc3164message (c , hdr , buff , len (buff ), syslogparser .ErrEOL )
77
83
}
78
84
79
- func (s * Rfc3164TestSuite ) TestParseTimestamp_TooLong (c * C ) {
80
- // XXX : <15 chars
81
- buff := []byte ("aaa" )
82
- ts := new (time.Time )
83
-
84
- s .assertTimestamp (c , * ts , buff , len (buff ), syslogparser .ErrEOL )
85
- }
86
-
87
85
func (s * Rfc3164TestSuite ) TestParseTimestamp_Invalid (c * C ) {
88
86
buff := []byte ("Oct 34 32:72:82" )
89
87
ts := new (time.Time )
90
88
91
- s .assertTimestamp (c , * ts , buff , len ( buff ) , syslogparser .ErrTimestampUnknownFormat )
89
+ s .assertTimestamp (c , * ts , buff , lastTriedTimestampLen , syslogparser .ErrTimestampUnknownFormat )
92
90
}
93
91
94
92
func (s * Rfc3164TestSuite ) TestParseTimestamp_TrailingSpace (c * C ) {
@@ -102,6 +100,17 @@ func (s *Rfc3164TestSuite) TestParseTimestamp_TrailingSpace(c *C) {
102
100
s .assertTimestamp (c , ts , buff , len (buff ), nil )
103
101
}
104
102
103
+ func (s * Rfc3164TestSuite ) TestParseTimestamp_OneDigitForMonths (c * C ) {
104
+ // XXX : no year specified. Assumed current year
105
+ // XXX : no timezone specified. Assume UTC
106
+ buff := []byte ("Oct 1 22:14:15" )
107
+
108
+ now := time .Now ()
109
+ ts := time .Date (now .Year (), time .October , 1 , 22 , 14 , 15 , 0 , time .UTC )
110
+
111
+ s .assertTimestamp (c , ts , buff , len (buff ), nil )
112
+ }
113
+
105
114
func (s * Rfc3164TestSuite ) TestParseTimestamp_Valid (c * C ) {
106
115
// XXX : no year specified. Assumed current year
107
116
// XXX : no timezone specified. Assume UTC
0 commit comments