Fix tests

This commit is contained in:
Dimitar Dimitrov 2023-12-13 10:49:30 +01:00
parent f4cd11318c
commit f388b77fdc
No known key found for this signature in database
GPG key ID: 4541B04E6C90EBC3

View file

@ -58,7 +58,7 @@ func TestPostingsForMatchersCache(t *testing.T) {
}, &timeNowMock{}, false) }, &timeNowMock{}, false)
_, err := c.PostingsForMatchers(ctx, indexForPostingsMock{}, true, expectedMatchers...) _, err := c.PostingsForMatchers(ctx, indexForPostingsMock{}, true, expectedMatchers...)
require.Equal(t, expectedErr, err) require.ErrorIs(t, err, expectedErr)
}) })
t.Run("happy case multiple concurrent calls: two same one different", func(t *testing.T) { t.Run("happy case multiple concurrent calls: two same one different", func(t *testing.T) {
@ -110,7 +110,7 @@ func TestPostingsForMatchersCache(t *testing.T) {
return nil, fmt.Errorf(matchersString(ms)) return nil, fmt.Errorf(matchersString(ms))
}, &timeNowMock{}, forced) }, &timeNowMock{}, forced)
results := make([]string, len(calls)) results := make([]error, len(calls))
resultsWg := sync.WaitGroup{} resultsWg := sync.WaitGroup{}
resultsWg.Add(len(calls)) resultsWg.Add(len(calls))
@ -118,7 +118,7 @@ func TestPostingsForMatchersCache(t *testing.T) {
for i := 0; i < len(calls); i++ { for i := 0; i < len(calls); i++ {
go func(i int) { go func(i int) {
_, err := c.PostingsForMatchers(ctx, indexForPostingsMock{}, concurrent, calls[i]...) _, err := c.PostingsForMatchers(ctx, indexForPostingsMock{}, concurrent, calls[i]...)
results[i] = err.Error() results[i] = err
resultsWg.Done() resultsWg.Done()
}(i) }(i)
} }
@ -136,7 +136,7 @@ func TestPostingsForMatchersCache(t *testing.T) {
// check that we got correct results // check that we got correct results
for i, c := range calls { for i, c := range calls {
require.Equal(t, matchersString(c), results[i], "Call %d should have returned error %q, but got %q instead", i, matchersString(c), results[i]) require.ErrorContainsf(t, results[i], matchersString(c), "Call %d should have returned error %q, but got %q instead", i, matchersString(c), results[i])
} }
}) })
} }