mirror of
https://github.com/mattermost/mattermost.git
synced 2026-08-10 04:58:22 -05:00
MM-68532: default EnableSearchPublicChannelsWithoutMembership to true for new installations (#36399)
* MM-68532: default EnableSearchPublicChannelsWithoutMembership to true for new installations * fix test: disable backfill in watcher tests to avoid mock store panic * fix test: mock System store so backfill returns early in watcher tests * MM-68532: add SetDefaults unit test for EnableSearchPublicChannelsWithoutMembership
This commit is contained in:
@@ -18,6 +18,7 @@ import (
|
||||
"github.com/mattermost/mattermost/server/public/model"
|
||||
"github.com/mattermost/mattermost/server/public/shared/mlog"
|
||||
"github.com/mattermost/mattermost/server/public/shared/request"
|
||||
storemocks "github.com/mattermost/mattermost/server/v8/channels/store/storetest/mocks"
|
||||
"github.com/mattermost/mattermost/server/v8/channels/testlib"
|
||||
"github.com/mattermost/mattermost/server/v8/platform/services/searchengine"
|
||||
searchenginemocks "github.com/mattermost/mattermost/server/v8/platform/services/searchengine/mocks"
|
||||
@@ -64,6 +65,14 @@ func setupWatcherTest(t *testing.T) (*searchEngineWatcher, *searchenginemocks.Se
|
||||
engineMock.On("IsHealthy").Return(true).Maybe()
|
||||
engineMock.On("SetHealthy", mock.Anything).Maybe()
|
||||
|
||||
// Make backfillPostsChannelType return immediately by indicating the backfill
|
||||
// is already done. This prevents the goroutine from calling unmocked store
|
||||
// methods in tests that only exercise watcher retry/health logic.
|
||||
systemMock := &storemocks.SystemStore{}
|
||||
systemMock.On("GetByName", model.SystemPostChannelTypeBackfillComplete).
|
||||
Return(&model.System{Name: model.SystemPostChannelTypeBackfillComplete, Value: "true"}, nil).Maybe()
|
||||
ps.Store.(*storemocks.Store).On("System").Return(systemMock).Maybe()
|
||||
|
||||
ps.SearchEngine = searchengine.NewBroker(ps.Config())
|
||||
ps.SearchEngine.ElasticsearchEngine = engineMock
|
||||
|
||||
|
||||
@@ -3273,7 +3273,7 @@ func (s *ElasticsearchSettings) SetDefaults() {
|
||||
}
|
||||
|
||||
if s.EnableSearchPublicChannelsWithoutMembership == nil {
|
||||
s.EnableSearchPublicChannelsWithoutMembership = NewPointer(false)
|
||||
s.EnableSearchPublicChannelsWithoutMembership = NewPointer(true)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3001,3 +3001,17 @@ func TestExperimentalSettingsEnableWatermarkDefault(t *testing.T) {
|
||||
require.True(t, *cfg.ExperimentalSettings.EnableWatermark)
|
||||
})
|
||||
}
|
||||
|
||||
func TestElasticsearchSettingsSetDefaults(t *testing.T) {
|
||||
t.Run("EnableSearchPublicChannelsWithoutMembership defaults to true when nil", func(t *testing.T) {
|
||||
s := ElasticsearchSettings{}
|
||||
s.SetDefaults()
|
||||
require.True(t, *s.EnableSearchPublicChannelsWithoutMembership)
|
||||
})
|
||||
|
||||
t.Run("EnableSearchPublicChannelsWithoutMembership preserves explicit false", func(t *testing.T) {
|
||||
s := ElasticsearchSettings{EnableSearchPublicChannelsWithoutMembership: NewPointer(false)}
|
||||
s.SetDefaults()
|
||||
require.False(t, *s.EnableSearchPublicChannelsWithoutMembership)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user