@@ -140,38 +140,25 @@ func TestFindMaxAge(t *testing.T) {
140140 {"max-age=100" , 100 },
141141 {"public, max-age=100" , 100 },
142142 {"public,max-age=100" , 100 },
143+ {"public, max-age=100, must-revalidate, no-transform" , 100 },
144+ {"" , 0 },
145+ {"max-age 100" , 0 },
146+ {"max-age: 100" , 0 },
147+ {"max-age2=100" , 0 },
148+ {"max-age=foo" , 0 },
149+ {"private," , 0 },
143150 }
144151 for _ , tc := range cases {
145152 resp := & http.Response {
146153 Header : http.Header {"Cache-Control" : {tc .cc }},
147154 }
148- age , err := findMaxAge (resp )
149- if err != nil {
150- t .Errorf ("findMaxAge(%q) = %v" , tc .cc , err )
151- } else if * age != (time .Duration (tc .want ) * time .Second ) {
155+ age := findMaxAge (resp )
156+ if * age != (time .Duration (tc .want ) * time .Second ) {
152157 t .Errorf ("findMaxAge(%q) = %v; want = %v" , tc .cc , * age , tc .want )
153158 }
154159 }
155160}
156161
157- func TestFindMaxAgeError (t * testing.T ) {
158- cases := []string {
159- "" ,
160- "max-age 100" ,
161- "max-age: 100" ,
162- "max-age2=100" ,
163- "max-age=foo" ,
164- }
165- for _ , tc := range cases {
166- resp := & http.Response {
167- Header : http.Header {"Cache-Control" : []string {tc }},
168- }
169- if age , err := findMaxAge (resp ); age != nil || err == nil {
170- t .Errorf ("findMaxAge(%q) = (%v, %v); want = (nil, err)" , tc , age , err )
171- }
172- }
173- }
174-
175162func TestParsePublicKeys (t * testing.T ) {
176163 b , err := ioutil .ReadFile ("../testdata/public_certs.json" )
177164 if err != nil {
0 commit comments