MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / TestCacheableFail

Function TestCacheableFail

auth/oidc_test.go:756–789  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

754}
755
756func TestCacheableFail(t *testing.T) {
757 tests := []struct {
758 name string
759 header http.Header
760 wantTTL time.Duration
761 wantOK bool
762 }{{
763 name: "invalid Cache-Control short-circuits",
764 header: http.Header{
765 "Cache-Control": []string{"max-age"},
766 "Date": []string{"Thu, 01 Dec 1983 22:00:00 GMT"},
767 "Expires": []string{"Fri, 02 Dec 1983 01:00:00 GMT"},
768 },
769 wantTTL: 0,
770 wantOK: false,
771 }, {
772 name: "no Cache-Control invalid Expires",
773 header: http.Header{
774 "Date": []string{"Thu, 01 Dec 1983 22:00:00 GMT"},
775 "Expires": []string{"boo"},
776 },
777 wantTTL: 0,
778 wantOK: false,
779 }}
780
781 for _, tc := range tests {
782 t.Run(tc.name, func(t *testing.T) {
783 ttl, ok, err := cacheable(tc.header)
784 require.Error(t, err, "No error checking max age and expiry")
785 assert.Equal(t, tc.wantTTL, ttl, "TTL mismatch")
786 assert.Equal(t, tc.wantOK, ok, " incorrect ok value")
787 })
788 }
789}
790
791func TestCacheControlMaxAgePass(t *testing.T) {
792 tests := []struct {

Callers

nothing calls this directly

Calls 4

cacheableFunction · 0.85
RunMethod · 0.65
ErrorMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected