Alerting: decouple api models from domain\dto models: separate Provenance status + converters (#63594)
* move conversions of domain models to api models and reverse from definition package to api package
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
|
||||
)
|
||||
|
||||
func TestToModel(t *testing.T) {
|
||||
t.Run("if no rules are provided the rule field should be nil", func(t *testing.T) {
|
||||
ruleGroup := definitions.AlertRuleGroup{
|
||||
Title: "123",
|
||||
FolderUID: "123",
|
||||
Interval: 10,
|
||||
}
|
||||
tm, err := AlertRuleGroupFromApi(ruleGroup)
|
||||
require.NoError(t, err)
|
||||
require.Nil(t, tm.Rules)
|
||||
})
|
||||
t.Run("if rules are provided the rule field should be not nil", func(t *testing.T) {
|
||||
ruleGroup := definitions.AlertRuleGroup{
|
||||
Title: "123",
|
||||
FolderUID: "123",
|
||||
Interval: 10,
|
||||
Rules: []definitions.ProvisionedAlertRule{
|
||||
{
|
||||
UID: "1",
|
||||
},
|
||||
},
|
||||
}
|
||||
tm, err := AlertRuleGroupFromApi(ruleGroup)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, tm.Rules, 1)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user