Fix flaky TestCreatePost and others (#29320)

We don't clear the Redis cache for every test.
This can cause issues because the cache is shared
across test. We fix that with this PR.
```release-note
NONE
```
Этот коммит содержится в:
Agniva De Sarker
2024-11-19 14:23:37 +05:30
коммит произвёл GitHub
родитель aa0d117f30
Коммит c6a7a8f628
2 изменённых файлов: 6 добавлений и 2 удалений

Просмотреть файл

@@ -44,6 +44,8 @@ func StoreOverride(override any) Option {
}
}
// StoreOverrideWithCache is a test option to construct the app with the store layer
// wrapped on top of the store that is passed.
func StoreOverrideWithCache(override store.Store) Option {
return func(ps *PlatformService) error {
ps.newStore = func() (store.Store, error) {
@@ -51,6 +53,9 @@ func StoreOverrideWithCache(override store.Store) Option {
if err != nil {
return nil, err
}
// Clearing all the caches because the in-mem data
// is persisted in case of Redis.
lcl.Invalidate()
return lcl, nil
}