fork of https://github.com/sourcegraph/zoekt
0

Configure Feed

Select the types of activity you want to include in your feed.

Fix rare failures in ngram selection tests (#805)

If `maxFreq=0` then `rand.Intn` will panic. This PR ensures it is always >= 1.

Example failure: https://github.com/sourcegraph/zoekt/actions/runs/10301894396/job/28514416201?pr=804

+6
+6
indexdata_test.go
··· 42 42 // worse, so what we do instead is just validate that what we get back is 43 43 // acceptable. 44 44 if err := quick.Check(func(s string, maxFreq uint16) bool { 45 + // Ensure maximum frequency is nonzero so that random sampling will work 46 + maxFreq = max(maxFreq, 1) 47 + 45 48 ngramOffs := splitNGrams([]byte(s)) 46 49 if len(ngramOffs) == 0 { 47 50 return true ··· 75 78 76 79 func TestFindSelectiveNGrams(t *testing.T) { 77 80 if err := quick.Check(func(s string, maxFreq uint16) bool { 81 + // Ensure maximum frequency is nonzero so that random sampling will work 82 + maxFreq = max(maxFreq, 1) 83 + 78 84 ngramOffs := splitNGrams([]byte(s)) 79 85 if len(ngramOffs) == 0 { 80 86 return true