go test -run Test_Session_WithContext_StorageError
(t *testing.T)
| 2076 | |
| 2077 | // go test -run Test_Session_WithContext_StorageError |
| 2078 | func Test_Session_WithContext_StorageError(t *testing.T) { |
| 2079 | t.Parallel() |
| 2080 | |
| 2081 | storageErr := errors.New("storage unavailable") |
| 2082 | |
| 2083 | t.Run("DestroyWithContext propagates storage error", func(t *testing.T) { |
| 2084 | t.Parallel() |
| 2085 | sess := newSessionWithStorage(t, &failingStorage{err: storageErr}) |
| 2086 | sess.Set("name", "fenny") |
| 2087 | require.ErrorIs(t, sess.DestroyWithContext(t.Context()), storageErr) |
| 2088 | // A failed delete must not wipe the in-memory session. |
| 2089 | require.Equal(t, "fenny", sess.Get("name")) |
| 2090 | }) |
| 2091 | |
| 2092 | t.Run("RegenerateWithContext propagates storage error", func(t *testing.T) { |
| 2093 | t.Parallel() |
| 2094 | sess := newSessionWithStorage(t, &failingStorage{err: storageErr}) |
| 2095 | require.ErrorIs(t, sess.RegenerateWithContext(t.Context()), storageErr) |
| 2096 | }) |
| 2097 | |
| 2098 | t.Run("ResetWithContext propagates storage error", func(t *testing.T) { |
| 2099 | t.Parallel() |
| 2100 | sess := newSessionWithStorage(t, &failingStorage{err: storageErr}) |
| 2101 | sess.Set("name", "fenny") |
| 2102 | require.ErrorIs(t, sess.ResetWithContext(t.Context()), storageErr) |
| 2103 | // A failed delete must not wipe the in-memory session. |
| 2104 | require.Equal(t, "fenny", sess.Get("name")) |
| 2105 | }) |
| 2106 | |
| 2107 | t.Run("SaveWithContext propagates storage error", func(t *testing.T) { |
| 2108 | t.Parallel() |
| 2109 | sess := newSessionWithStorage(t, &failingStorage{err: storageErr}) |
| 2110 | sess.Set("name", "fenny") |
| 2111 | require.ErrorIs(t, sess.SaveWithContext(t.Context()), storageErr) |
| 2112 | }) |
| 2113 | } |
| 2114 | |
| 2115 | // go test -run Test_Session_WithContext_CanceledContext |
| 2116 | func Test_Session_WithContext_CanceledContext(t *testing.T) { |
nothing calls this directly
no test coverage detected