bccc980b90
* Add unified_alerting.notification_history to ini files
* Parse notification history settings
* Move Loki client to a separate package
* Loki client: add params for metrics and traces
* add NotificationHistorian
* rm writeDuration
* remove RangeQuery stuff
* wip
* wip
* wip
* wip
* pass notification historian in tests
* unify loki settings
* unify loki settings
* add test
* update grafana/alerting
* make update-workspace
* add feature toggle
* fix configureNotificationHistorian
* Revert "add feature toggle"
This reverts commit de7af8f7
* add feature toggle
* more tests
* RuleUID
* fix metrics test
* met.Info.Set(0)
46 lines
954 B
Go
46 lines
954 B
Go
package lokiclient
|
|
|
|
import (
|
|
"bytes"
|
|
"io"
|
|
"net/http"
|
|
)
|
|
|
|
type FakeRequester struct {
|
|
LastRequest *http.Request
|
|
Resp *http.Response
|
|
}
|
|
|
|
func NewFakeRequester() *FakeRequester {
|
|
return &FakeRequester{
|
|
Resp: &http.Response{
|
|
Status: "200 OK",
|
|
StatusCode: 200,
|
|
Body: io.NopCloser(bytes.NewBufferString("")),
|
|
ContentLength: int64(0),
|
|
Header: make(http.Header, 0),
|
|
},
|
|
}
|
|
}
|
|
|
|
func (f *FakeRequester) WithResponse(resp *http.Response) *FakeRequester {
|
|
f.Resp = resp
|
|
return f
|
|
}
|
|
|
|
func (f *FakeRequester) Do(req *http.Request) (*http.Response, error) {
|
|
f.LastRequest = req
|
|
f.Resp.Request = req // Not concurrency-safe!
|
|
return f.Resp, nil
|
|
}
|
|
|
|
func BadResponse() *http.Response {
|
|
return &http.Response{
|
|
Status: "400 Bad Request",
|
|
StatusCode: http.StatusBadRequest,
|
|
Body: io.NopCloser(bytes.NewBufferString("")),
|
|
ContentLength: int64(0),
|
|
Header: make(http.Header, 0),
|
|
}
|
|
}
|