mirror of https://github.com/grafana/grafana
Alerting: Fix export of notification policy to JSON (#78021)
* Export Notification Policy correctly (#78020) The JSON version of an exported Notification Policy now inline correctly the policy in the same way the Yaml version does. Co-authored-by: Yuri Tseretyan <yuriy.tseretyan@grafana.com>pull/79047/head
parent
99580d60f5
commit
ab83bc7346
@ -0,0 +1,30 @@ |
||||
package definitions |
||||
|
||||
import ( |
||||
"encoding/json" |
||||
"testing" |
||||
|
||||
"github.com/stretchr/testify/require" |
||||
"gopkg.in/yaml.v3" |
||||
) |
||||
|
||||
func TestNotificationPolicyExportMarshal(t *testing.T) { |
||||
c := true |
||||
npe := &NotificationPolicyExport{ |
||||
OrgID: 1, |
||||
RouteExport: &RouteExport{ |
||||
Receiver: "receiver", |
||||
Continue: &c, |
||||
}, |
||||
} |
||||
t.Run("json", func(t *testing.T) { |
||||
val, err := json.Marshal(npe) |
||||
require.NoError(t, err) |
||||
require.Equal(t, "{\"orgId\":1,\"receiver\":\"receiver\",\"continue\":true}", string(val)) |
||||
}) |
||||
t.Run("yaml", func(t *testing.T) { |
||||
val, err := yaml.Marshal(npe) |
||||
require.NoError(t, err) |
||||
require.Equal(t, "orgId: 1\nreceiver: receiver\ncontinue: true\n", string(val)) |
||||
}) |
||||
} |
||||
Loading…
Reference in new issue