Test_Session_getExtractorInfo exercises the extractor-resolution branches directly, including the nil-config safe default and single (non-chained) configured extractors.
(t *testing.T)
| 811 | // directly, including the nil-config safe default and single (non-chained) |
| 812 | // configured extractors. |
| 813 | func Test_Session_getExtractorInfo(t *testing.T) { |
| 814 | t.Parallel() |
| 815 | |
| 816 | t.Run("nil config returns safe cookie default", func(t *testing.T) { |
| 817 | t.Parallel() |
| 818 | sess := &Session{} |
| 819 | got := sess.getExtractorInfo() |
| 820 | require.Len(t, got, 1) |
| 821 | require.Equal(t, extractors.SourceCookie, got[0].Source) |
| 822 | require.Equal(t, "session_id", got[0].Key) |
| 823 | }) |
| 824 | |
| 825 | t.Run("single cookie extractor", func(t *testing.T) { |
| 826 | t.Parallel() |
| 827 | store := NewStore(Config{Extractor: extractors.FromCookie("session_id")}) |
| 828 | sess := &Session{config: store} |
| 829 | got := sess.getExtractorInfo() |
| 830 | require.Len(t, got, 1) |
| 831 | require.Equal(t, extractors.SourceCookie, got[0].Source) |
| 832 | }) |
| 833 | |
| 834 | t.Run("single header extractor", func(t *testing.T) { |
| 835 | t.Parallel() |
| 836 | store := NewStore(Config{Extractor: extractors.FromHeader("x-session-id")}) |
| 837 | sess := &Session{config: store} |
| 838 | got := sess.getExtractorInfo() |
| 839 | require.Len(t, got, 1) |
| 840 | require.Equal(t, extractors.SourceHeader, got[0].Source) |
| 841 | }) |
| 842 | |
| 843 | t.Run("single read-only extractor yields no writable sink", func(t *testing.T) { |
| 844 | t.Parallel() |
| 845 | store := NewStore(Config{Extractor: extractors.FromQuery("session_id")}) |
| 846 | sess := &Session{config: store} |
| 847 | require.Empty(t, sess.getExtractorInfo()) |
| 848 | }) |
| 849 | } |
| 850 | |
| 851 | func Test_Session_Save_IdleTimeout(t *testing.T) { |
| 852 | t.Parallel() |
nothing calls this directly
no test coverage detected