@@ -61,59 +61,6 @@ func TestDateTimeString(tt *testing.T) {
6161 require .Equal (tt , `"` + expectedString + `"` , d .String ())
6262}
6363
64- func TestLongMonthDateUnmarshalJSON (tt * testing.T ) {
65- tests := []struct {
66- name string
67- input string
68- assert func (t * testing.T , date * models.LongMonthDate , err error )
69- }{
70- {
71- name : "empty string default" ,
72- input : "\" \" " ,
73- assert : func (t * testing.T , date * models.LongMonthDate , err error ) {
74- require .NotNil (t , date )
75- require .True (t , date .Time .IsZero ())
76- require .NoError (t , err )
77- },
78- },
79- {
80- name : "unknown bytes" ,
81- input : "\" ?>?>>L:\" " ,
82- assert : func (t * testing.T , date * models.LongMonthDate , err error ) {
83- require .NotNil (t , date )
84- require .True (t , date .Time .IsZero ())
85- require .EqualError (t , err , "parsing time \" ?>?>>L:\" as \" January 2, 2006\" : cannot parse \" ?>?>>L:\" as \" January\" " )
86- },
87- },
88- {
89- name : "successfully unmarshal" ,
90- input : "\" March 02, 2024\" " ,
91- assert : func (t * testing.T , date * models.LongMonthDate , err error ) {
92- ts , tErr := time .Parse (models .LongMonthDateFormat , "March 2, 2024" )
93- require .NoError (t , tErr )
94- require .NotNil (t , date )
95- require .Equal (t , ts , date .Time )
96- require .NoError (t , err )
97- },
98- },
99- }
100- for _ , test := range tests {
101- tt .Run (test .name , func (t * testing.T ) {
102- d := & models.LongMonthDate {}
103- err := d .UnmarshalJSON ([]byte (test .input ))
104- test .assert (t , d , err )
105- })
106- }
107- }
108-
109- func TestLongMonthDateString (tt * testing.T ) {
110- expectedString := "March 2, 2024"
111- t , err := time .Parse (models .LongMonthDateFormat , expectedString )
112- require .NoError (tt , err )
113- d := & models.LongMonthDate {t }
114- require .Equal (tt , `"` + expectedString + `"` , d .String ())
115- }
116-
11764func TestRFC3339NumColonTZUnmarshalJSON (tt * testing.T ) {
11865 tests := []struct {
11966 name string
0 commit comments