(t *testing.T)
| 849 | } |
| 850 | |
| 851 | func TestCacheControlMaxAgeFail(t *testing.T) { |
| 852 | tests := []struct { |
| 853 | name string |
| 854 | header http.Header |
| 855 | wantMaxAge time.Duration |
| 856 | wantOK bool |
| 857 | }{{ |
| 858 | name: "Cache-Control header with max-age directive that has non-integer value", |
| 859 | header: http.Header{ |
| 860 | "Cache-Control": []string{"max-age=foo"}, |
| 861 | }, |
| 862 | wantMaxAge: 0, |
| 863 | wantOK: false, |
| 864 | }, { |
| 865 | name: "Cache-Control header with max-age directive that has emnpty value", |
| 866 | header: http.Header{ |
| 867 | "Cache-Control": []string{"max-age="}, |
| 868 | }, |
| 869 | wantMaxAge: 0, |
| 870 | wantOK: false, |
| 871 | }, { |
| 872 | name: "Cache-Control header with max-age directive that has no value", |
| 873 | header: http.Header{ |
| 874 | "Cache-Control": []string{"max-age"}, |
| 875 | }, |
| 876 | wantMaxAge: 0, |
| 877 | wantOK: false, |
| 878 | }} |
| 879 | |
| 880 | for _, tc := range tests { |
| 881 | t.Run(tc.name, func(t *testing.T) { |
| 882 | maxAge, ok, err := cacheControlMaxAge(tc.header) |
| 883 | require.Error(t, err, "No error checking max age and expiry") |
| 884 | assert.Equal(t, tc.wantMaxAge, maxAge, "max age mismatch") |
| 885 | assert.Equal(t, tc.wantOK, ok, " incorrect ok value") |
| 886 | }) |
| 887 | } |
| 888 | } |
| 889 | |
| 890 | func TestGetDiscoveryEndpoint(t *testing.T) { |
| 891 | tests := []struct { |
nothing calls this directly
no test coverage detected