Alerting: Remove mis-behaving fake and fix masked test failure in AM config API (#47747) (#47751)

* Remove misbehaving fake

* Fix bug and inject logger

(cherry picked from commit c266a4ac81)

Co-authored-by: Alexander Weaver <weaver.alex.d@gmail.com>
This commit is contained in:
Grot (@grafanabot)
2022-04-14 02:49:37 +02:00
committed by GitHub
co-authored by Alexander Weaver
parent 0e8ba02479
commit 37e5b0fbc7
3 changed files with 12 additions and 33 deletions
-26
View File
@@ -1,43 +1,17 @@
package api
import (
"context"
"fmt"
"sync"
"testing"
"time"
"github.com/grafana/grafana/pkg/services/ngalert/eval"
"github.com/grafana/grafana/pkg/services/ngalert/models"
"github.com/grafana/grafana/pkg/services/ngalert/state"
"github.com/grafana/grafana/pkg/services/ngalert/store"
"github.com/grafana/grafana-plugin-sdk-go/data"
)
type FakeAlertingStore struct {
orgsWithConfig map[int64]bool
}
func newFakeAlertingStore(t *testing.T) FakeAlertingStore {
t.Helper()
return FakeAlertingStore{
orgsWithConfig: map[int64]bool{},
}
}
func (f FakeAlertingStore) Setup(orgID int64) {
f.orgsWithConfig[orgID] = true
}
func (f FakeAlertingStore) GetLatestAlertmanagerConfiguration(_ context.Context, query *models.GetLatestAlertmanagerConfigurationQuery) error {
if _, ok := f.orgsWithConfig[query.OrgID]; ok {
return nil
}
return store.ErrNoAlertmanagerConfiguration
}
type fakeAlertInstanceManager struct {
mtx sync.Mutex
// orgID -> RuleID -> States