* Create API test for overwriting invalid alertmanager config * Avoid requiring alertmanager readiness for config changes * AlertmanagerSrv depends on functionality rather than concrete types * Add test for non-ready alertmanagers * Additional cleanup and polish * Back out previous integration test changes * Refactor of tests incorrectly caused a test to become redundant * Use pre-existing fake secret service * Drop unused interface * Test against concrete MultiOrgAlertmanager re-using fake infra from other tests * Fix linter error * Empty commit to rerun checks
32 lines
680 B
Go
32 lines
680 B
Go
package api
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/grafana/grafana/pkg/services/ngalert/models"
|
|
"github.com/grafana/grafana/pkg/services/ngalert/store"
|
|
)
|
|
|
|
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(query *models.GetLatestAlertmanagerConfigurationQuery) error {
|
|
if _, ok := f.orgsWithConfig[query.OrgID]; ok {
|
|
return nil
|
|
}
|
|
return store.ErrNoAlertmanagerConfiguration
|
|
}
|