forked from grafana/loki
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testutils.go
73 lines (59 loc) · 2.44 KB
/
testutils.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package querier
import (
"context"
"github.com/grafana/dskit/flagext"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/model/labels"
"github.com/prometheus/prometheus/scrape"
"github.com/stretchr/testify/mock"
"github.com/frelon/loki/v2/pkg/ingester/client"
"github.com/frelon/loki/v2/pkg/prom1/storage/metric"
base_querier "github.com/frelon/loki/v2/pkg/querier/base"
"github.com/frelon/loki/v2/pkg/util/validation"
)
type MockDistributor struct {
mock.Mock
}
func (m *MockDistributor) Query(ctx context.Context, from, to model.Time, matchers ...*labels.Matcher) (model.Matrix, error) {
args := m.Called(ctx, from, to, matchers)
return args.Get(0).(model.Matrix), args.Error(1)
}
func (m *MockDistributor) QueryExemplars(ctx context.Context, from, to model.Time, matchers ...[]*labels.Matcher) (*client.ExemplarQueryResponse, error) {
args := m.Called(ctx, from, to, matchers)
return args.Get(0).(*client.ExemplarQueryResponse), args.Error(1)
}
func (m *MockDistributor) QueryStream(ctx context.Context, from, to model.Time, matchers ...*labels.Matcher) (*client.QueryStreamResponse, error) {
args := m.Called(ctx, from, to, matchers)
return args.Get(0).(*client.QueryStreamResponse), args.Error(1)
}
func (m *MockDistributor) LabelValuesForLabelName(ctx context.Context, from, to model.Time, lbl model.LabelName, matchers ...*labels.Matcher) ([]string, error) {
args := m.Called(ctx, from, to, lbl, matchers)
return args.Get(0).([]string), args.Error(1)
}
func (m *MockDistributor) LabelNames(ctx context.Context, from, to model.Time) ([]string, error) {
args := m.Called(ctx, from, to)
return args.Get(0).([]string), args.Error(1)
}
func (m *MockDistributor) MetricsForLabelMatchers(ctx context.Context, from, to model.Time, matchers ...*labels.Matcher) ([]metric.Metric, error) {
args := m.Called(ctx, from, to, matchers)
return args.Get(0).([]metric.Metric), args.Error(1)
}
func (m *MockDistributor) MetricsMetadata(ctx context.Context) ([]scrape.MetricMetadata, error) {
args := m.Called(ctx)
return args.Get(0).([]scrape.MetricMetadata), args.Error(1)
}
type TestConfig struct {
Cfg Config
Distributor base_querier.Distributor
Stores []base_querier.QueryableWithFilter
}
func DefaultQuerierConfig() Config {
querierCfg := Config{}
flagext.DefaultValues(&querierCfg)
return querierCfg
}
func DefaultLimitsConfig() validation.Limits {
limits := validation.Limits{}
flagext.DefaultValues(&limits)
return limits
}