(t *testing.T)
| 419 | } |
| 420 | |
| 421 | func TestBlockBaseQuerier_LabelNamesLimit(t *testing.T) { |
| 422 | ix := newMockIndex() |
| 423 | ls := labels.FromStrings("aaa", "1", "bbb", "2", "ccc", "3") |
| 424 | require.NoError(t, ix.AddSeries(1, ls)) |
| 425 | ls.Range(func(lbl labels.Label) { |
| 426 | require.NoError(t, ix.WritePostings(lbl.Name, lbl.Value, index.NewListPostings([]storage.SeriesRef{1}))) |
| 427 | }) |
| 428 | |
| 429 | q := &blockBaseQuerier{index: ix, chunks: mockChunkReader(nil), tombstones: tombstones.NewMemTombstones()} |
| 430 | |
| 431 | t.Run("no limit", func(t *testing.T) { |
| 432 | names, _, err := q.LabelNames(context.Background(), nil) |
| 433 | require.NoError(t, err) |
| 434 | require.Equal(t, []string{"aaa", "bbb", "ccc"}, names) |
| 435 | }) |
| 436 | |
| 437 | t.Run("limit applied", func(t *testing.T) { |
| 438 | names, _, err := q.LabelNames(context.Background(), &storage.LabelHints{Limit: 2}) |
| 439 | require.NoError(t, err) |
| 440 | require.Equal(t, []string{"aaa", "bbb"}, names) |
| 441 | }) |
| 442 | |
| 443 | t.Run("limit larger than result", func(t *testing.T) { |
| 444 | names, _, err := q.LabelNames(context.Background(), &storage.LabelHints{Limit: 10}) |
| 445 | require.NoError(t, err) |
| 446 | require.Equal(t, []string{"aaa", "bbb", "ccc"}, names) |
| 447 | }) |
| 448 | |
| 449 | t.Run("zero limit means no limit", func(t *testing.T) { |
| 450 | names, _, err := q.LabelNames(context.Background(), &storage.LabelHints{Limit: 0}) |
| 451 | require.NoError(t, err) |
| 452 | require.Equal(t, []string{"aaa", "bbb", "ccc"}, names) |
| 453 | }) |
| 454 | } |
| 455 | |
| 456 | func TestBlockQuerier_AgainstHeadWithOpenChunks(t *testing.T) { |
| 457 | for _, c := range []blockQuerierTestCase{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…