Skip to content

Commit

Permalink
filtering/safesearch: added test for brave search engine
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianLang06 committed Jan 6, 2025
1 parent 306472b commit bd48661
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions internal/filtering/safesearch/safesearch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ var testConf = filtering.SafeSearchConfig{
Enabled: true,

Bing: true,
Brave: true,
DuckDuckGo: true,
Ecosia: true,
Google: true,
Expand Down Expand Up @@ -220,3 +221,27 @@ func TestDefault_Update(t *testing.T) {

assert.False(t, res.IsFiltered)
}

func TestDefault_CheckHost_brave(t *testing.T) {
ctx := testutil.ContextWithTimeout(t, testTimeout)
ss, err := safesearch.NewDefault(ctx, &safesearch.DefaultConfig{
Logger: slogutil.NewDiscardLogger(),
ServicesConfig: testConf,
CacheSize: testCacheSize,
CacheTTL: testCacheTTL,
})
require.NoError(t, err)

host := "search.brave.com"

t.Run(host, func(t *testing.T) {
var res filtering.Result
res, err = ss.CheckHost(ctx, host, testQType)
require.NoError(t, err)

assert.True(t, res.IsFiltered)
assert.Equal(t, filtering.FilteredSafeSearch, res.Reason)
assert.Equal(t, "safesearch.brave.com", res.CanonName)
assert.Empty(t, res.Rules)
})
}

0 comments on commit bd48661

Please sign in to comment.