|
| 1 | +package v1 |
| 2 | + |
| 3 | +import ( |
| 4 | + "context" |
| 5 | + "time" |
| 6 | + |
| 7 | + "github.com/prometheus/common/model" |
| 8 | +) |
| 9 | + |
| 10 | +type FakeAPI struct { |
| 11 | + // FakeAPI is a mock API for testing purposes. |
| 12 | + // It implements the API interface and provides fake data for testing. |
| 13 | + ExpectedAlertsResult []*Alert |
| 14 | + ExpectedAlertsError error |
| 15 | + |
| 16 | + ExpectedAlertManagersResult AlertManagersResult |
| 17 | + ExpectedAlertManagersError error |
| 18 | + |
| 19 | + ExpectedCleanTombstonesError error |
| 20 | + |
| 21 | + ExpectedConfigResult ConfigResult |
| 22 | + ExpectedConfigError error |
| 23 | + |
| 24 | + ExpectedDeleteSeriesError error |
| 25 | + |
| 26 | + ExpectedFlagsResult FlagsResult |
| 27 | + ExpectedFlagsError error |
| 28 | + |
| 29 | + ExpectedLabelNamesResult []string |
| 30 | + ExpectedLabelNamesWarnings Warnings |
| 31 | + ExpectedLabelNamesError error |
| 32 | + |
| 33 | + ExpectedLabelValuesResult model.LabelValues |
| 34 | + ExpectedLabelValuesWarnings Warnings |
| 35 | + ExpectedLabelValuesError error |
| 36 | + |
| 37 | + ExpectedQueryResult model.Value |
| 38 | + ExpectedQueryWarnings Warnings |
| 39 | + ExpectedQueryError error |
| 40 | + |
| 41 | + ExpectedQueryRangeResult model.Value |
| 42 | + ExpectedQueryRangeWarnings Warnings |
| 43 | + ExpectedQueryRangeError error |
| 44 | + |
| 45 | + ExpectedQueryExemplarsResult []ExemplarQueryResult |
| 46 | + ExpectedQueryExemplarsError error |
| 47 | + |
| 48 | + ExpectedBuildinfoResult BuildinfoResult |
| 49 | + ExpectedBuildinfoError error |
| 50 | + |
| 51 | + ExpectedRuntimeinfoResult RuntimeinfoResult |
| 52 | + ExpectedRuntimeinfoError error |
| 53 | + |
| 54 | + ExpectedSeriesResult []model.LabelSet |
| 55 | + ExpectedSeriesWarnings Warnings |
| 56 | + ExpectedSeriesError error |
| 57 | + |
| 58 | + ExpectedSnapshotResult SnapshotResult |
| 59 | + ExpectedSnapshotError error |
| 60 | + |
| 61 | + ExpectedRulesResult RulesResult |
| 62 | + ExpectedRulesError error |
| 63 | + |
| 64 | + ExpectedTargetsResult TargetsResult |
| 65 | + ExpectedTargetsError error |
| 66 | + |
| 67 | + ExpectedTargetsMetadataResult []MetricMetadata |
| 68 | + ExpectedTargetsMetadataError error |
| 69 | + |
| 70 | + ExpectedMetadataResult map[string][]Metadata |
| 71 | + ExpectedMetadataError error |
| 72 | + |
| 73 | + ExpectedTSDBResult TSDBResult |
| 74 | + ExpectedTSDBError error |
| 75 | + |
| 76 | + ExpectedWalReplayResult WalReplayStatus |
| 77 | + ExpectedWalReplayError error |
| 78 | +} |
| 79 | + |
| 80 | +func (f *FakeAPI) Alerts(ctx context.Context) ([]*Alert, error) { |
| 81 | + return f.ExpectedAlertsResult, f.ExpectedAlertsError |
| 82 | +} |
| 83 | + |
| 84 | +func (f *FakeAPI) AlertManagers(ctx context.Context) (AlertManagersResult, error) { |
| 85 | + return f.ExpectedAlertManagersResult, f.ExpectedAlertManagersError |
| 86 | +} |
| 87 | + |
| 88 | +func (f *FakeAPI) CleanTombstones(ctx context.Context) error { |
| 89 | + return f.ExpectedCleanTombstonesError |
| 90 | +} |
| 91 | + |
| 92 | +func (f *FakeAPI) Config(ctx context.Context) (ConfigResult, error) { |
| 93 | + return f.ExpectedConfigResult, f.ExpectedConfigError |
| 94 | +} |
| 95 | + |
| 96 | +func (f *FakeAPI) DeleteSeries(ctx context.Context, matches []string, startTime, endTime time.Time) error { |
| 97 | + return f.ExpectedDeleteSeriesError |
| 98 | +} |
| 99 | +func (f *FakeAPI) Flags(ctx context.Context) (FlagsResult, error) { |
| 100 | + return f.ExpectedFlagsResult, f.ExpectedFlagsError |
| 101 | +} |
| 102 | + |
| 103 | +func (f *FakeAPI) LabelNames(ctx context.Context, matches []string, startTime, endTime time.Time, opts ...Option) ([]string, Warnings, error) { |
| 104 | + return f.ExpectedLabelNamesResult, f.ExpectedLabelNamesWarnings, f.ExpectedLabelNamesError |
| 105 | +} |
| 106 | + |
| 107 | +func (f *FakeAPI) LabelValues(ctx context.Context, label string, matches []string, startTime, endTime time.Time, opts ...Option) (model.LabelValues, Warnings, error) { |
| 108 | + return f.ExpectedLabelValuesResult, f.ExpectedLabelValuesWarnings, f.ExpectedLabelValuesError |
| 109 | +} |
| 110 | + |
| 111 | +func (f *FakeAPI) Query(ctx context.Context, query string, ts time.Time, opts ...Option) (model.Value, Warnings, error) { |
| 112 | + return f.ExpectedQueryResult, f.ExpectedQueryWarnings, f.ExpectedQueryError |
| 113 | +} |
| 114 | + |
| 115 | +func (f *FakeAPI) QueryRange(ctx context.Context, query string, r Range, opts ...Option) (model.Value, Warnings, error) { |
| 116 | + return f.ExpectedQueryRangeResult, f.ExpectedQueryRangeWarnings, f.ExpectedQueryRangeError |
| 117 | +} |
| 118 | + |
| 119 | +func (f *FakeAPI) QueryExemplars(ctx context.Context, query string, startTime, endTime time.Time) ([]ExemplarQueryResult, error) { |
| 120 | + return f.ExpectedQueryExemplarsResult, f.ExpectedQueryExemplarsError |
| 121 | +} |
| 122 | + |
| 123 | +func (f *FakeAPI) Buildinfo(ctx context.Context) (BuildinfoResult, error) { |
| 124 | + return f.ExpectedBuildinfoResult, f.ExpectedBuildinfoError |
| 125 | +} |
| 126 | + |
| 127 | +func (f *FakeAPI) Runtimeinfo(ctx context.Context) (RuntimeinfoResult, error) { |
| 128 | + return f.ExpectedRuntimeinfoResult, f.ExpectedRuntimeinfoError |
| 129 | +} |
| 130 | + |
| 131 | +func (f *FakeAPI) Series(ctx context.Context, matches []string, startTime, endTime time.Time, opts ...Option) ([]model.LabelSet, Warnings, error) { |
| 132 | + return f.ExpectedSeriesResult, f.ExpectedSeriesWarnings, f.ExpectedSeriesError |
| 133 | +} |
| 134 | + |
| 135 | +func (f *FakeAPI) Snapshot(ctx context.Context, skipHead bool) (SnapshotResult, error) { |
| 136 | + return f.ExpectedSnapshotResult, f.ExpectedSnapshotError |
| 137 | +} |
| 138 | + |
| 139 | +func (f *FakeAPI) Rules(ctx context.Context) (RulesResult, error) { |
| 140 | + return f.ExpectedRulesResult, f.ExpectedRulesError |
| 141 | +} |
| 142 | + |
| 143 | +func (f *FakeAPI) Targets(ctx context.Context) (TargetsResult, error) { |
| 144 | + return f.ExpectedTargetsResult, f.ExpectedTargetsError |
| 145 | +} |
| 146 | + |
| 147 | +func (f *FakeAPI) TargetsMetadata(ctx context.Context, matchTarget, metric, limit string) ([]MetricMetadata, error) { |
| 148 | + return f.ExpectedTargetsMetadataResult, f.ExpectedTargetsMetadataError |
| 149 | +} |
| 150 | + |
| 151 | +func (f *FakeAPI) Metadata(ctx context.Context, metric, limit string) (map[string][]Metadata, error) { |
| 152 | + return f.ExpectedMetadataResult, f.ExpectedMetadataError |
| 153 | +} |
| 154 | + |
| 155 | +func (f *FakeAPI) TSDB(ctx context.Context, opts ...Option) (TSDBResult, error) { |
| 156 | + return f.ExpectedTSDBResult, f.ExpectedTSDBError |
| 157 | +} |
| 158 | + |
| 159 | +func (f *FakeAPI) WalReplay(ctx context.Context) (WalReplayStatus, error) { |
| 160 | + return f.ExpectedWalReplayResult, f.ExpectedWalReplayError |
| 161 | +} |
0 commit comments